2020-04-22 23:15:05 +08:00
|
|
|
cmake_minimum_required(VERSION 3.13.4)
|
2016-02-05 15:00:13 +08:00
|
|
|
|
2017-11-30 03:31:48 +08:00
|
|
|
# Add cmake directory to search for custom cmake functions.
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
|
|
|
|
2017-11-30 03:31:43 +08:00
|
|
|
# llvm/runtimes/ will set OPENMP_STANDALONE_BUILD.
|
|
|
|
if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
set(OPENMP_STANDALONE_BUILD TRUE)
|
|
|
|
project(openmp C CXX)
|
|
|
|
|
|
|
|
# CMAKE_BUILD_TYPE was not set, default to Release.
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
|
|
|
|
2017-11-30 03:31:48 +08:00
|
|
|
# Group common settings.
|
|
|
|
set(OPENMP_ENABLE_WERROR FALSE CACHE BOOL
|
|
|
|
"Enable -Werror flags to turn warnings into errors for supporting compilers.")
|
|
|
|
set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING
|
2017-12-27 17:15:10 +08:00
|
|
|
"Suffix of lib installation directory, e.g. 64 => lib64")
|
2018-05-25 23:56:41 +08:00
|
|
|
# Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR.
|
|
|
|
set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}")
|
2017-11-30 03:31:48 +08:00
|
|
|
|
2017-11-30 03:31:52 +08:00
|
|
|
# Group test settings.
|
|
|
|
set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING
|
|
|
|
"C compiler to use for testing OpenMP runtime libraries.")
|
|
|
|
set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING
|
|
|
|
"C++ compiler to use for testing OpenMP runtime libraries.")
|
2017-11-30 03:31:43 +08:00
|
|
|
set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.")
|
2017-11-30 03:31:48 +08:00
|
|
|
else()
|
|
|
|
set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR})
|
|
|
|
# If building in tree, we honor the same install suffix LLVM uses.
|
2018-05-25 23:56:41 +08:00
|
|
|
set(OPENMP_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}")
|
2017-11-30 03:31:52 +08:00
|
|
|
|
|
|
|
if (NOT MSVC)
|
|
|
|
set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
|
|
|
|
set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
|
|
|
|
else()
|
|
|
|
set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang.exe)
|
|
|
|
set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe)
|
|
|
|
endif()
|
2017-11-30 03:31:43 +08:00
|
|
|
endif()
|
2016-02-05 15:00:13 +08:00
|
|
|
|
2017-11-30 03:31:48 +08:00
|
|
|
# Check and set up common compiler flags.
|
|
|
|
include(config-ix)
|
|
|
|
include(HandleOpenMPOptions)
|
|
|
|
|
2017-11-30 03:31:52 +08:00
|
|
|
# Set up testing infrastructure.
|
|
|
|
include(OpenMPTesting)
|
|
|
|
|
|
|
|
set(OPENMP_TEST_FLAGS "" CACHE STRING
|
|
|
|
"Extra compiler flags to send to the test compiler.")
|
2017-12-01 01:08:31 +08:00
|
|
|
set(OPENMP_TEST_OPENMP_FLAGS ${OPENMP_TEST_COMPILER_OPENMP_FLAGS} CACHE STRING
|
2017-11-30 03:31:52 +08:00
|
|
|
"OpenMP compiler flag to use for testing OpenMP runtime libraries.")
|
|
|
|
|
2017-11-23 01:15:18 +08:00
|
|
|
set(ENABLE_LIBOMPTARGET ON)
|
2017-03-22 02:19:09 +08:00
|
|
|
# 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.
|
2020-02-12 07:08:48 +08:00
|
|
|
if (APPLE OR WIN32 OR NOT OPENMP_HAVE_STD_CPP14_FLAG)
|
2017-07-26 21:55:00 +08:00
|
|
|
set(ENABLE_LIBOMPTARGET OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
|
|
|
|
${ENABLE_LIBOMPTARGET})
|
2020-12-11 03:24:27 +08:00
|
|
|
option(OPENMP_ENABLE_LIBOMPTARGET_PROFILING "Enable time profiling for libomptarget."
|
|
|
|
${ENABLE_LIBOMPTARGET})
|
2021-01-28 20:24:19 +08:00
|
|
|
option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
|
2021-01-26 06:10:50 +08:00
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2017-07-26 21:55:00 +08:00
|
|
|
if (OPENMP_ENABLE_LIBOMPTARGET)
|
2020-01-04 11:03:42 +08:00
|
|
|
# Check that the library can actually be built.
|
2017-11-30 03:31:48 +08:00
|
|
|
if (APPLE OR WIN32)
|
|
|
|
message(FATAL_ERROR "libomptarget cannot be built on Windows and MacOS X!")
|
2020-02-12 07:08:48 +08:00
|
|
|
elseif (NOT OPENMP_HAVE_STD_CPP14_FLAG)
|
|
|
|
message(FATAL_ERROR "Host compiler must support C++14 to build libomptarget!")
|
2017-11-30 03:31:48 +08:00
|
|
|
endif()
|
|
|
|
|
2017-02-11 01:13:28 +08:00
|
|
|
add_subdirectory(libomptarget)
|
|
|
|
endif()
|
2017-11-30 03:31:52 +08:00
|
|
|
|
2019-11-18 08:23:31 +08:00
|
|
|
set(ENABLE_OMPT_TOOLS ON)
|
|
|
|
# Currently tools are not tested well on Windows or MacOS X.
|
|
|
|
if (APPLE OR WIN32)
|
|
|
|
set(ENABLE_OMPT_TOOLS OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(OPENMP_ENABLE_OMPT_TOOLS "Enable building ompt based tools for OpenMP."
|
|
|
|
${ENABLE_OMPT_TOOLS})
|
|
|
|
if (OPENMP_ENABLE_OMPT_TOOLS)
|
|
|
|
add_subdirectory(tools)
|
|
|
|
endif()
|
|
|
|
|
2020-09-17 05:15:56 +08:00
|
|
|
|
|
|
|
# Build documentation
|
|
|
|
add_subdirectory(docs)
|
|
|
|
|
2020-04-04 11:06:29 +08:00
|
|
|
# Now that we have seen all testsuites, create the check-openmp target.
|
2017-11-30 03:31:52 +08:00
|
|
|
construct_check_openmp_target()
|