[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / openmp / libomptarget / plugins / CMakeLists.txt
blobac156785c9a0f643f19b7f060edb9e43235b521f
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 plugins for the user system if available.
11 ##===----------------------------------------------------------------------===##
13 add_subdirectory(common)
15 # void build_generic_elf64(string tmachine, string tmachine_name, string tmachine_libname, string elf_machine_id);
16 # - build a plugin for an ELF based generic 64-bit target based on libffi.
17 # - tmachine: name of the machine processor as used in the cmake build system.
18 # - tmachine_name: name of the machine to be printed with the debug messages.
19 # - tmachine_libname: machine name to be appended to the plugin library name.
20 macro(build_generic_elf64 tmachine tmachine_name tmachine_libname tmachine_triple elf_machine_id)
21 if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
22   if(LIBOMPTARGET_DEP_LIBELF_FOUND)
23     if(LIBOMPTARGET_DEP_LIBFFI_FOUND)
25       libomptarget_say("Building ${tmachine_name} offloading plugin.")
27       include_directories(${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR})
28       include_directories(${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR})
30       # Define macro to be used as prefix of the runtime messages for this target.
31       add_definitions("-DTARGET_NAME=${tmachine_name}")
33       # Define macro with the ELF ID for this target.
34       add_definitions("-DTARGET_ELF_ID=${elf_machine_id}")
36       add_library("omptarget.rtl.${tmachine_libname}" SHARED
37         ${CMAKE_CURRENT_SOURCE_DIR}/../generic-elf-64bit/src/rtl.cpp)
39       # Install plugin under the lib destination folder.
40       install(TARGETS "omptarget.rtl.${tmachine_libname}"
41         LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
43       target_link_libraries(
44         "omptarget.rtl.${tmachine_libname}"
45         elf_common
46         ${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
47         ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES}
48         dl
49         ${OPENMP_PTHREAD_LIB}
50         "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports")
52       list(APPEND LIBOMPTARGET_TESTED_PLUGINS
53         "omptarget.rtl.${tmachine_libname}")
55       # Report to the parent scope that we are building a plugin.
56       set(LIBOMPTARGET_SYSTEM_TARGETS
57         "${LIBOMPTARGET_SYSTEM_TARGETS} ${tmachine_triple}" PARENT_SCOPE)
58       set(LIBOMPTARGET_TESTED_PLUGINS
59         "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)
61     else(LIBOMPTARGET_DEP_LIBFFI_FOUND)
62       libomptarget_say("Not building ${tmachine_name} offloading plugin: libffi dependency not found.")
63     endif(LIBOMPTARGET_DEP_LIBFFI_FOUND)
64   else(LIBOMPTARGET_DEP_LIBELF_FOUND)
65     libomptarget_say("Not building ${tmachine_name} offloading plugin: libelf dependency not found.")
66   endif(LIBOMPTARGET_DEP_LIBELF_FOUND)
67 else()
68   libomptarget_say("Not building ${tmachine_name} offloading plugin: machine not found in the system.")
69 endif()
70 endmacro()
72 add_subdirectory(aarch64)
73 add_subdirectory(amdgpu)
74 add_subdirectory(cuda)
75 add_subdirectory(ppc64)
76 add_subdirectory(ppc64le)
77 add_subdirectory(ve)
78 add_subdirectory(x86_64)
79 add_subdirectory(remote)
81 # Make sure the parent scope can see the plugins that will be created.
82 set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE)
83 set(LIBOMPTARGET_TESTED_PLUGINS "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)