diff --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt index 540139dbcd042..5a1386f0bfe85 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 $) set(LINK_TOOL $) set(OPT_TOOL $) diff --git a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake index 61704a101e72f..1f2a50667c4fd 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