[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / openmp / libomptarget / src / CMakeLists.txt
blob376e8318bd2c69dc3330d3c9fd8cffd2c5408bf2
1 ##===----------------------------------------------------------------------===##
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 ##===----------------------------------------------------------------------===##
9 # Build offloading library libomptarget.so.
11 ##===----------------------------------------------------------------------===##
13 libomptarget_say("Building offloading runtime library libomptarget.")
15 set(LIBOMPTARGET_SRC_FILES
16   ${CMAKE_CURRENT_SOURCE_DIR}/api.cpp
17   ${CMAKE_CURRENT_SOURCE_DIR}/device.cpp
18   ${CMAKE_CURRENT_SOURCE_DIR}/interface.cpp
19   ${CMAKE_CURRENT_SOURCE_DIR}/rtl.cpp
20   ${CMAKE_CURRENT_SOURCE_DIR}/omptarget.cpp
23 set(LIBOMPTARGET_SRC_FILES ${LIBOMPTARGET_SRC_FILES} PARENT_SCOPE)
25 include_directories(${LIBOMPTARGET_LLVM_INCLUDE_DIRS})
27 # Build libomptarget library with libdl dependency.
28 add_library(omptarget SHARED ${LIBOMPTARGET_SRC_FILES})
29 set_target_properties(omptarget PROPERTIES INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN")
30 if (OPENMP_ENABLE_LIBOMPTARGET_PROFILING)
31   # Add LLVMSupport dependency if profiling is enabled.
32   # Linking with LLVM component libraries also requires
33   # aligning the compile flags.
34   llvm_update_compile_flags(omptarget)
35   target_compile_definitions(omptarget PUBLIC OMPTARGET_PROFILE_ENABLED)
36   target_link_libraries(omptarget PRIVATE LLVMSupport)
37 endif()
38 target_link_libraries(omptarget PRIVATE
39   ${CMAKE_DL_LIBS}
40   "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports")
42 # Install libomptarget under the lib destination folder.
43 install(TARGETS omptarget LIBRARY COMPONENT omptarget
44   DESTINATION "${OPENMP_INSTALL_LIBDIR}")