[JITLink][arm64] Support arm64e JIT'd code (initially enabled for MachO only).
[llvm-project.git] / offload / src / CMakeLists.txt
blobc5f5d902fad14c036e2773bf9c3ce3a69365aa9e
1 message(STATUS "Building offloading runtime library libomptarget.")
3 if(LIBOMP_STANDALONE)
4   set(LIBOMP ${LIBOMP_STANDALONE})
5 else()
6   set(LIBOMP omp)
7 endif()
9 add_llvm_library(omptarget
10   SHARED
12   device.cpp
13   interface.cpp
14   omptarget.cpp
15   OffloadRTL.cpp
16   LegacyAPI.cpp
17   PluginManager.cpp
18   DeviceImage.cpp
20   OpenMP/API.cpp
21   OpenMP/Mapping.cpp
22   OpenMP/InteropAPI.cpp
23   OpenMP/OMPT/Callback.cpp
25   KernelLanguage/API.cpp
27   ADDITIONAL_HEADER_DIRS
28   ${LIBOMPTARGET_INCLUDE_DIR}
29   ${LIBOMPTARGET_BINARY_INCLUDE_DIR}
31   LINK_COMPONENTS
32   FrontendOpenMP
33   Support
34   Object
36   LINK_LIBS
37   PUBLIC
38   ${LIBOMP}
40   NO_INSTALL_RPATH
41   BUILDTREE_ONLY
43 target_include_directories(omptarget PRIVATE
44   ${LIBOMPTARGET_INCLUDE_DIR} ${LIBOMPTARGET_BINARY_INCLUDE_DIR}
47 if (LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
48   target_link_libraries(omptarget PRIVATE
49     "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports")
50 endif()
52 # Define the TARGET_NAME and DEBUG_PREFIX.
53 target_compile_definitions(omptarget PRIVATE
54   TARGET_NAME=omptarget
55   DEBUG_PREFIX="omptarget"
58 foreach(plugin IN LISTS LIBOMPTARGET_PLUGINS_TO_BUILD)
59   target_link_libraries(omptarget PRIVATE omptarget.rtl.${plugin})
60 endforeach()
62 target_compile_options(omptarget PRIVATE ${offload_compile_flags})
63 target_link_options(omptarget PRIVATE ${offload_link_flags})
65 # libomptarget.so needs to be aware of where the plugins live as they
66 # are now separated in the build directory.
67 set_target_properties(omptarget PROPERTIES
68                       POSITION_INDEPENDENT_CODE ON
69                       INSTALL_RPATH "$ORIGIN"
70                       BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..")
71 install(TARGETS omptarget LIBRARY COMPONENT omptarget DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")