|
| 1 | +#=============================================================================== |
| 2 | +# Copyright 2025 SiPearl |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, |
| 11 | +# software distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions |
| 14 | +# and limitations under the License. |
| 15 | +# |
| 16 | +# |
| 17 | +# SPDX-License-Identifier: Apache-2.0 |
| 18 | +#=============================================================================== |
| 19 | + |
| 20 | +set(LIB_NAME onemath_dft_armpl) |
| 21 | +set(LIB_OBJ ${LIB_NAME}_obj) |
| 22 | + |
| 23 | +include(WarningsUtils) |
| 24 | + |
| 25 | +# Add third-party library |
| 26 | +find_package(ARMPL REQUIRED) |
| 27 | + |
| 28 | +add_library(${LIB_NAME}) |
| 29 | +add_deprecated_library(${LIB_NAME}) |
| 30 | +add_library(${LIB_OBJ} OBJECT |
| 31 | + descriptor.cpp |
| 32 | + commit.cpp |
| 33 | + forward.cpp |
| 34 | + backward.cpp |
| 35 | + $<$<BOOL:${BUILD_SHARED_LIBS}>: armpl_wrappers.cpp> |
| 36 | +) |
| 37 | +add_dependencies(onemath_backend_libs_dft ${LIB_NAME}) |
| 38 | + |
| 39 | +target_include_directories(${LIB_OBJ} |
| 40 | + PUBLIC ${ONEMATH_INCLUDE_DIRS} |
| 41 | + PRIVATE ${PROJECT_SOURCE_DIR}/src/include |
| 42 | + ${PROJECT_SOURCE_DIR}/src |
| 43 | + ${CMAKE_BINARY_DIR}/bin |
| 44 | + ${ARMPL_INCLUDE} |
| 45 | + ${ONEMATH_GENERATED_INCLUDE_PATH} |
| 46 | +) |
| 47 | + |
| 48 | +target_compile_options(${LIB_OBJ} PRIVATE ${ONEMATH_BUILD_COPT} ${ARMPL_COPT}) |
| 49 | +if (USE_ADD_SYCL_TO_TARGET_INTEGRATION) |
| 50 | + add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES}) |
| 51 | +endif() |
| 52 | + |
| 53 | +target_link_libraries(${LIB_OBJ} |
| 54 | + PUBLIC ONEMATH::SYCL::SYCL ${ARMPL_LINK} |
| 55 | + PRIVATE onemath_warnings |
| 56 | +) |
| 57 | + |
| 58 | +set_target_properties(${LIB_OBJ} PROPERTIES |
| 59 | + POSITION_INDEPENDENT_CODE ON |
| 60 | +) |
| 61 | +target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ}) |
| 62 | +target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS}) |
| 63 | + |
| 64 | +#Set oneMath libraries as not transitive for dynamic |
| 65 | +if(BUILD_SHARED_LIBS) |
| 66 | + set_target_properties(${LIB_NAME} PROPERTIES |
| 67 | + INTERFACE_LINK_LIBRARIES ONEMATH::SYCL::SYCL |
| 68 | + ) |
| 69 | +endif() |
| 70 | + |
| 71 | +# Add major version to the library |
| 72 | +set_target_properties(${LIB_NAME} PROPERTIES |
| 73 | + SOVERSION ${PROJECT_VERSION_MAJOR} |
| 74 | +) |
| 75 | + |
| 76 | +# Add dependencies rpath to the library |
| 77 | +list(APPEND CMAKE_BUILD_RPATH $<TARGET_FILE_DIR:${LIB_NAME}>) |
| 78 | + |
| 79 | +# Add the library to install package |
| 80 | +install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets) |
| 81 | +install(TARGETS ${LIB_NAME} EXPORT oneMathTargets |
| 82 | + RUNTIME DESTINATION bin |
| 83 | + ARCHIVE DESTINATION lib |
| 84 | + LIBRARY DESTINATION lib |
| 85 | +) |
0 commit comments