1 cmake_minimum_required(VERSION 3.13.4)
3 # Add cmake directory to search for custom cmake functions.
4 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
6 # llvm/runtimes/ will set OPENMP_STANDALONE_BUILD.
7 if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
8 set(OPENMP_STANDALONE_BUILD TRUE)
11 # CMAKE_BUILD_TYPE was not set, default to Release.
12 if (NOT CMAKE_BUILD_TYPE)
13 set(CMAKE_BUILD_TYPE Release)
16 # Group common settings.
17 set(OPENMP_ENABLE_WERROR FALSE CACHE BOOL
18 "Enable -Werror flags to turn warnings into errors for supporting compilers.")
19 set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING
20 "Suffix of lib installation directory, e.g. 64 => lib64")
21 # Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR.
22 set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}")
24 # Group test settings.
25 set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING
26 "C compiler to use for testing OpenMP runtime libraries.")
27 set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING
28 "C++ compiler to use for testing OpenMP runtime libraries.")
29 set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.")
31 set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR})
32 # If building in tree, we honor the same install suffix LLVM uses.
33 set(OPENMP_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}")
36 set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
37 set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
39 set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang.exe)
40 set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe)
44 # Check and set up common compiler flags.
46 include(HandleOpenMPOptions)
48 # Set up testing infrastructure.
49 include(OpenMPTesting)
51 set(OPENMP_TEST_FLAGS "" CACHE STRING
52 "Extra compiler flags to send to the test compiler.")
53 set(OPENMP_TEST_OPENMP_FLAGS ${OPENMP_TEST_COMPILER_OPENMP_FLAGS} CACHE STRING
54 "OpenMP compiler flag to use for testing OpenMP runtime libraries.")
56 set(ENABLE_LIBOMPTARGET ON)
57 # Currently libomptarget cannot be compiled on Windows or MacOS X.
58 # Since the device plugins are only supported on Linux anyway,
59 # there is no point in trying to compile libomptarget on other OSes.
60 if (APPLE OR WIN32 OR NOT OPENMP_HAVE_STD_CPP14_FLAG)
61 set(ENABLE_LIBOMPTARGET OFF)
64 set(ENABLE_LIBOMPTARGET_PROFILING OFF)
65 if (ENABLE_LIBOMPTARGET AND NOT LLVM_RUNTIMES_BUILD)
66 set(ENABLE_LIBOMPTARGET_PROFILING ON)
69 option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
70 ${ENABLE_LIBOMPTARGET})
71 option(OPENMP_ENABLE_LIBOMPTARGET_PROFILING "Enable time profiling for libomptarget."
72 ${ENABLE_LIBOMPTARGET_PROFILING})
73 option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
75 # Build host runtime library, after LIBOMPTARGET variables are set since they are needed
76 # to enable time profiling support in the OpenMP runtime.
77 add_subdirectory(runtime)
80 add_subdirectory(libompd)
82 if (OPENMP_ENABLE_LIBOMPTARGET)
83 # Check that the library can actually be built.
85 message(FATAL_ERROR "libomptarget cannot be built on Windows and MacOS X!")
86 elseif (NOT OPENMP_HAVE_STD_CPP14_FLAG)
87 message(FATAL_ERROR "Host compiler must support C++14 to build libomptarget!")
90 add_subdirectory(libomptarget)
93 set(ENABLE_OMPT_TOOLS ON)
94 # Currently tools are not tested well on Windows or MacOS X.
96 set(ENABLE_OMPT_TOOLS OFF)
99 option(OPENMP_ENABLE_OMPT_TOOLS "Enable building ompt based tools for OpenMP."
100 ${ENABLE_OMPT_TOOLS})
101 if (OPENMP_ENABLE_OMPT_TOOLS)
102 add_subdirectory(tools)
105 option(OPENMP_MSVC_NAME_SCHEME "Build dll with MSVC naming scheme." OFF)
107 # Build documentation
108 add_subdirectory(docs)
110 # Now that we have seen all testsuites, create the check-openmp target.
111 construct_check_openmp_target()