diff --git a/offload/plugins-nextgen/CMakeLists.txt b/offload/plugins-nextgen/CMakeLists.txt index d1079f8a3e9cc..79f1c6dc66e85 100644 --- a/offload/plugins-nextgen/CMakeLists.txt +++ b/offload/plugins-nextgen/CMakeLists.txt @@ -16,7 +16,6 @@ add_subdirectory(common) function(add_target_library target_name lib_name) add_llvm_library(${target_name} STATIC LINK_COMPONENTS - ${LLVM_TARGETS_TO_BUILD} AggressiveInstCombine Analysis BinaryFormat diff --git a/offload/plugins-nextgen/common/CMakeLists.txt b/offload/plugins-nextgen/common/CMakeLists.txt index a470dcee6d859..6064468ea5b57 100644 --- a/offload/plugins-nextgen/common/CMakeLists.txt +++ b/offload/plugins-nextgen/common/CMakeLists.txt @@ -22,9 +22,13 @@ add_library(PluginCommon OBJECT add_dependencies(PluginCommon intrinsics_gen) # Only enable JIT for those targets that LLVM can support. -string(TOUPPER "${LLVM_TARGETS_TO_BUILD}" TargetsSupported) -foreach(Target ${TargetsSupported}) - target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${Target}") +set(supported_jit_targets AMDGPU NVPTX) +foreach(target IN LISTS supported_jit_targets) + if("${target}" IN_LIST LLVM_TARGETS_TO_BUILD) + target_compile_definitions(PluginCommon PRIVATE "LIBOMPTARGET_JIT_${target}") + llvm_map_components_to_libnames(llvm_libs ${target}) + target_link_libraries(PluginCommon PRIVATE ${llvm_libs}) + endif() endforeach() # Include the RPC server from the `libc` project if availible.