diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt --- a/openmp/CMakeLists.txt +++ b/openmp/CMakeLists.txt @@ -53,32 +53,14 @@ set(OPENMP_TEST_OPENMP_FLAGS ${OPENMP_TEST_COMPILER_OPENMP_FLAGS} CACHE STRING "OpenMP compiler flag to use for testing OpenMP runtime libraries.") -set(ENABLE_LIBOMPTARGET ON) -# Currently libomptarget cannot be compiled on Windows or MacOS X. -# Since the device plugins are only supported on Linux anyway, -# there is no point in trying to compile libomptarget on other OSes. -if (APPLE OR WIN32 OR NOT OPENMP_HAVE_STD_CPP14_FLAG) - set(ENABLE_LIBOMPTARGET OFF) -endif() - -option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading." - ${ENABLE_LIBOMPTARGET}) -option(OPENMP_ENABLE_LIBOMPTARGET_PROFILING "Enable time profiling for libomptarget." - ${ENABLE_LIBOMPTARGET}) option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF) # Build host runtime library, after LIBOMPTARGET variables are set since they are needed # to enable time profiling support in the OpenMP runtime. add_subdirectory(runtime) +option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading." ON) if (OPENMP_ENABLE_LIBOMPTARGET) - # Check that the library can actually be built. - if (APPLE OR WIN32) - message(FATAL_ERROR "libomptarget cannot be built on Windows and MacOS X!") - elseif (NOT OPENMP_HAVE_STD_CPP14_FLAG) - message(FATAL_ERROR "Host compiler must support C++14 to build libomptarget!") - endif() - add_subdirectory(libomptarget) endif() @@ -94,7 +76,6 @@ add_subdirectory(tools) endif() - # Build documentation add_subdirectory(docs) diff --git a/openmp/libomptarget/CMakeLists.txt b/openmp/libomptarget/CMakeLists.txt --- a/openmp/libomptarget/CMakeLists.txt +++ b/openmp/libomptarget/CMakeLists.txt @@ -27,12 +27,24 @@ # Message utilities. include(LibomptargetUtils) +if (APPLE OR WIN32) + libomptarget_say("libomptarget can only work on Linux for now. Will not build libomptarget.") + return() +endif() + +if (NOT OPENMP_HAVE_STD_CPP14_FLAG) + libomptarget_say("Building libomptarget requires the compiler support C++14. Will not build libomptarget.") + return() +endif() + # Get dependencies for the different components of the project. include(LibomptargetGetDependencies) -# LLVM source tree is required at build time for libomptarget +# LLVM source tree is required at build time for libomptarget. If it is missing, +# libomptarget will not be built. if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS) - message(FATAL_ERROR "Missing definition for LIBOMPTARGET_LLVM_INCLUDE_DIRS") + libomptarget_say("Building libomptarget requires LLVM 12.0+ components. Will not build libomptarget.") + return() endif() # This is a list of all the targets that are supported/tested right now. @@ -61,6 +73,8 @@ add_definitions(-DOMPTARGET_DEBUG) endif() +option(OPENMP_ENABLE_LIBOMPTARGET_PROFILING "Enable time profiling for libomptarget." ON) + set(LIBOMPTARGET_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) include_directories(${LIBOMPTARGET_INCLUDE_DIR}) @@ -74,7 +88,6 @@ set(LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER "${LIBOMP_LIBRARY_DIR}" CACHE STRING "Path to folder containing libomp.so, and libLLVMSupport.so with profiling enabled") - # Build offloading plugins and device RTLs if they are available. add_subdirectory(plugins) add_subdirectory(deviceRTLs) diff --git a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake --- a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake +++ b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake @@ -26,7 +26,13 @@ if (OPENMP_STANDALONE_BUILD) # Complete LLVM package is required for building libomptarget # in an out-of-tree mode. - find_package(LLVM REQUIRED) + find_package(LLVM 12 QUIET) + if (NOT LLVM_FOUND) + # Return here directly as if `libomptarget` is not built, there is no reason + # to continue finding dependences for deviceRTLs or plugins. + return() + endif() + message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Using LLVM in: ${LLVM_DIR}") list(APPEND LIBOMPTARGET_LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) 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,11 +30,6 @@ return() endif() -if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS) - libomptarget_say("Not building AMDGPU plugin: Missing definition for LIBOMPTARGET_LLVM_INCLUDE_DIRS") - return() -endif() - libomptarget_say("Building amdgpu offloading plugin") ################################################################################