Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / libomptarget / plugins-nextgen / common / PluginInterface / CMakeLists.txt
blobdeecda2732bb5290b1d7791d07d1d185f2adceb1
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 # Common parts which can be used by all plugins
11 ##===----------------------------------------------------------------------===##
13 # NOTE: Don't try to build `PluginInterface` using `add_llvm_library` because we
14 # don't want to export `PluginInterface` while `add_llvm_library` requires that.
15 add_library(PluginInterface OBJECT
16   PluginInterface.cpp GlobalHandler.cpp JIT.cpp RPC.cpp)
18 # Only enable JIT for those targets that LLVM can support.
19 string(TOUPPER "${LLVM_TARGETS_TO_BUILD}" TargetsSupported)
20 foreach(Target ${TargetsSupported})
21   target_compile_definitions(PluginInterface PRIVATE "LIBOMPTARGET_JIT_${Target}")
22 endforeach()
24 # This is required when using LLVM libraries.
25 llvm_update_compile_flags(PluginInterface)
27 if (LLVM_LINK_LLVM_DYLIB)
28   set(llvm_libs LLVM)
29 else()
30   llvm_map_components_to_libnames(llvm_libs
31     ${LLVM_TARGETS_TO_BUILD}
32     AggressiveInstCombine
33     Analysis
34     BinaryFormat
35     BitReader
36     BitWriter
37     CodeGen
38     Core
39     Extensions
40     InstCombine
41     Instrumentation
42     IPO
43     IRReader
44     Linker
45     MC
46     Object
47     Passes
48     Remarks
49     ScalarOpts
50     Support
51     Target
52     TargetParser
53     TransformUtils
54     Vectorize
55   )
56 endif()
58 target_link_libraries(PluginInterface
59   PUBLIC
60     ${llvm_libs}
61     elf_common
62     MemoryManager
65 # Include the RPC server from the `libc` project if availible.
66 if(TARGET llvmlibc_rpc_server AND ${LIBOMPTARGET_GPU_LIBC_SUPPORT})
67   target_link_libraries(PluginInterface PRIVATE llvmlibc_rpc_server)
68   target_compile_definitions(PluginInterface PRIVATE LIBOMPTARGET_RPC_SUPPORT)
69 elseif(${LIBOMPTARGET_GPU_LIBC_SUPPORT})
70   find_library(llvmlibc_rpc_server NAMES llvmlibc_rpc_server
71                PATHS ${LIBOMPTARGET_LLVM_LIBRARY_DIR} NO_DEFAULT_PATH)
72   if(llvmlibc_rpc_server)
73     target_link_libraries(PluginInterface PRIVATE llvmlibc_rpc_server)
74     target_compile_definitions(PluginInterface PRIVATE LIBOMPTARGET_RPC_SUPPORT)
75   endif()
76 endif()
78 if ((OMPT_TARGET_DEFAULT) AND (LIBOMPTARGET_OMPT_SUPPORT))
79   target_link_libraries(PluginInterface PUBLIC OMPT)
80 endif()
82 # Define the TARGET_NAME and DEBUG_PREFIX.
83 target_compile_definitions(PluginInterface PRIVATE
84   TARGET_NAME="PluginInterface"
85   DEBUG_PREFIX="PluginInterface"
88 target_include_directories(PluginInterface
89   INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
90   PRIVATE ${LIBOMPTARGET_INCLUDE_DIR}
93 set_target_properties(PluginInterface PROPERTIES
94   POSITION_INDEPENDENT_CODE ON
95   CXX_VISIBILITY_PRESET protected)