71 lines · plain
1message(STATUS "Building offloading runtime library libomptarget.")2 3if(LIBOMP_STANDALONE)4 set(LIBOMP ${LIBOMP_STANDALONE})5else()6 set(LIBOMP omp)7endif()8 9add_llvm_library(omptarget10 SHARED11 12 device.cpp13 interface.cpp14 omptarget.cpp15 OffloadRTL.cpp16 LegacyAPI.cpp17 PluginManager.cpp18 DeviceImage.cpp19 20 OpenMP/API.cpp21 OpenMP/Mapping.cpp22 OpenMP/InteropAPI.cpp23 OpenMP/OMPT/Callback.cpp24 25 KernelLanguage/API.cpp26 27 ADDITIONAL_HEADER_DIRS28 ${LIBOMPTARGET_INCLUDE_DIR}29 ${LIBOMPTARGET_BINARY_INCLUDE_DIR}30 31 LINK_COMPONENTS32 FrontendOpenMP33 Support34 Object35 36 LINK_LIBS37 PUBLIC38 ${LIBOMP}39 40 NO_INSTALL_RPATH41 BUILDTREE_ONLY42)43target_include_directories(omptarget PRIVATE44 ${LIBOMPTARGET_INCLUDE_DIR} ${LIBOMPTARGET_BINARY_INCLUDE_DIR}45)46 47if(LLVM_HAVE_LINK_VERSION_SCRIPT)48 target_link_libraries(omptarget PRIVATE "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports")49endif()50 51# Define the TARGET_NAME and DEBUG_PREFIX.52target_compile_definitions(omptarget PRIVATE53 TARGET_NAME=omptarget54 DEBUG_PREFIX="omptarget"55)56 57foreach(plugin IN LISTS LIBOMPTARGET_PLUGINS_TO_BUILD)58 target_link_libraries(omptarget PRIVATE omptarget.rtl.${plugin})59endforeach()60 61target_compile_options(omptarget PRIVATE ${offload_compile_flags})62target_link_options(omptarget PRIVATE ${offload_link_flags})63 64# libomptarget.so needs to be aware of where the plugins live as they65# are now separated in the build directory.66set_target_properties(omptarget PROPERTIES67 POSITION_INDEPENDENT_CODE ON68 INSTALL_RPATH "$ORIGIN"69 BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..")70install(TARGETS omptarget LIBRARY COMPONENT omptarget DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")71