56 lines · plain
1# The error codes in this header are shared with liboffload, so need to be2# generated from the same source.3include(TableGen)4file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)5set(LLVM_TARGET_DEFINITIONS ${CMAKE_CURRENT_SOURCE_DIR}/../../liboffload/API/OffloadAPI.td)6tablegen(OFFLOAD include/OffloadErrcodes.inc -gen-errcodes -I ${CMAKE_CURRENT_SOURCE_DIR}/../../liboffload/API)7tablegen(OFFLOAD include/OffloadInfo.inc -gen-info -I ${CMAKE_CURRENT_SOURCE_DIR}/../../liboffload/API)8add_public_tablegen_target(PluginErrcodes)9 10# NOTE: Don't try to build `PluginInterface` using `add_llvm_library` because we11# don't want to export `PluginInterface` while `add_llvm_library` requires that.12add_library(PluginCommon OBJECT13 src/PluginInterface.cpp14 src/GlobalHandler.cpp15 src/JIT.cpp16 src/RPC.cpp17 src/OffloadError.cpp18 src/Utils/ELF.cpp19)20add_dependencies(PluginCommon intrinsics_gen PluginErrcodes)21 22# Only enable JIT for those targets that LLVM can support.23set(supported_jit_targets AMDGPU NVPTX)24if (NOT LLVM_LINK_LLVM_DYLIB)25 foreach(target IN LISTS supported_jit_targets)26 if("${target}" IN_LIST LLVM_TARGETS_TO_BUILD)27 target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${target}")28 llvm_map_components_to_libnames(llvm_libs ${target})29 target_link_libraries(PluginCommon PRIVATE ${llvm_libs})30 endif()31 endforeach()32endif()33 34# Include the RPC server from the `libc` project.35include(FindLibcCommonUtils)36target_link_libraries(PluginCommon PRIVATE llvm-libc-common-utilities)37 38# Define the TARGET_NAME and DEBUG_PREFIX.39target_compile_definitions(PluginCommon PRIVATE40 TARGET_NAME="PluginInterface"41 DEBUG_PREFIX="PluginInterface"42)43 44target_compile_options(PluginCommon PUBLIC ${offload_compile_flags})45target_link_options(PluginCommon PUBLIC ${offload_link_flags})46 47target_include_directories(PluginCommon PUBLIC48 ${CMAKE_CURRENT_SOURCE_DIR}/include49 ${CMAKE_CURRENT_BINARY_DIR}/include50 ${LIBOMPTARGET_LLVM_INCLUDE_DIRS}51 ${LIBOMPTARGET_BINARY_INCLUDE_DIR}52 ${LIBOMPTARGET_INCLUDE_DIR}53)54 55set_target_properties(PluginCommon PROPERTIES POSITION_INDEPENDENT_CODE ON)56