aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Luo <yeluo@anl.gov>2022-06-18 21:08:18 -0500
committerYe Luo <yeluo@anl.gov>2022-06-18 21:08:53 -0500
commit54b45afb599ab81355170f00f9ffe41a88a2cea5 (patch)
treea0d5f97f61e76e2bd40b578a63a38f2c6e3bfad1
parent8df54a6a03a6d07e3053eff9806b450ec9193772 (diff)
downloadllvm-54b45afb599ab81355170f00f9ffe41a88a2cea5.zip
llvm-54b45afb599ab81355170f00f9ffe41a88a2cea5.tar.gz
llvm-54b45afb599ab81355170f00f9ffe41a88a2cea5.tar.bz2
[libomptarget]Add a trap for external omptarget from LLVM
Old LLVM installation may expose its internal omptarget CMake target when being used by find_package(LLVM) and caused issues in the CMake of libomptarget that is being built. Trap the issue early. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D128129
-rw-r--r--openmp/libomptarget/DeviceRTL/CMakeLists.txt2
-rw-r--r--openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake4
2 files changed, 6 insertions, 0 deletions
diff --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index 540139d..5a1386f 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -20,6 +20,7 @@ endif()
if (LLVM_DIR)
# Builds that use pre-installed LLVM have LLVM_DIR set.
+ # A standalone or LLVM_ENABLE_RUNTIMES=openmp build takes this route
find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR}
NO_DEFAULT_PATH)
@@ -32,6 +33,7 @@ if (LLVM_DIR)
endif()
elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT OPENMP_STANDALONE_BUILD)
# LLVM in-tree builds may use CMake target names to discover the tools.
+ # A LLVM_ENABLE_PROJECTS=openmp build takes this route
set(CLANG_TOOL $<TARGET_FILE:clang>)
set(LINK_TOOL $<TARGET_FILE:llvm-link>)
set(OPT_TOOL $<TARGET_FILE:opt>)
diff --git a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
index 61704a1..1f2a506 100644
--- a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
+++ b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
@@ -32,6 +32,10 @@ if (OPENMP_STANDALONE_BUILD)
list(APPEND LIBOMPTARGET_LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS})
list(APPEND CMAKE_MODULE_PATH ${LLVM_CMAKE_DIR})
include(AddLLVM)
+ if(TARGET omptarget)
+ message(FATAL_ERROR "CMake target 'omptarget' already exists. "
+ "Use an LLVM installation that doesn't expose its 'omptarget' target.")
+ endif()
else()
# Note that OPENMP_STANDALONE_BUILD is FALSE, when
# openmp is built with -DLLVM_ENABLE_RUNTIMES="openmp" vs