diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt --- a/openmp/CMakeLists.txt +++ b/openmp/CMakeLists.txt @@ -66,6 +66,20 @@ set(ENABLE_LIBOMPTARGET OFF) endif() +# Attempt to locate LLVM source, required by libomptarget +if (NOT LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR) + if (LLVM_MAIN_INCLUDE_DIR) + set(LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR}) + elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../llvm/include) + set(LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../llvm/include) + endif() +endif() + +if (NOT LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR) + message(STATUS "Missing definition for LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR, disabling libomptarget") + set(ENABLE_LIBOMPTARGET OFF) +endif() + option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading." ${ENABLE_LIBOMPTARGET}) if (OPENMP_ENABLE_LIBOMPTARGET) diff --git a/openmp/libomptarget/CMakeLists.txt b/openmp/libomptarget/CMakeLists.txt --- a/openmp/libomptarget/CMakeLists.txt +++ b/openmp/libomptarget/CMakeLists.txt @@ -29,6 +29,11 @@ # Get dependencies for the different components of the project. include(LibomptargetGetDependencies) +# LLVM source tree is required at build time for libomptarget +if (NOT LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR) + message(FATAL_ERROR "Missing definition for LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR") +endif() + # This is a list of all the targets that are supported/tested right now. set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} aarch64-unknown-linux-gnu") set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} powerpc64le-ibm-linux-gnu") diff --git a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt --- a/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt +++ b/openmp/libomptarget/plugins/amdgpu/CMakeLists.txt @@ -30,8 +30,8 @@ return() endif() -if (NOT LLVM_MAIN_INCLUDE_DIR) - libomptarget_say("Not building AMDGPU plugin: Missing definition for LLVM_MAIN_INCLUDE_DIR") +if (NOT LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR) + libomptarget_say("Not building AMDGPU plugin: Missing definition for LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR") return() endif() @@ -50,7 +50,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/impl - ${LLVM_MAIN_INCLUDE_DIR} + ${LIBOMPTARGET_LLVM_MAIN_INCLUDE_DIR} ) add_library(omptarget.rtl.amdgpu SHARED