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)
12 # Must go below project(..)
13 include(GNUInstallDirs)
15 if (OPENMP_STANDALONE_BUILD)
16 # CMAKE_BUILD_TYPE was not set, default to Release.
17 if (NOT CMAKE_BUILD_TYPE)
18 set(CMAKE_BUILD_TYPE Release)
21 # Group common settings.
22 set(OPENMP_ENABLE_WERROR FALSE CACHE BOOL
23 "Enable -Werror flags to turn warnings into errors for supporting compilers.")
24 set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING
25 "Suffix of lib installation directory, e.g. 64 => lib64")
26 # Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR.
27 set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}")
29 # Group test settings.
30 set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING
31 "C compiler to use for testing OpenMP runtime libraries.")
32 set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING
33 "C++ compiler to use for testing OpenMP runtime libraries.")
34 set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.")
36 set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR})
37 # If building in tree, we honor the same install suffix LLVM uses.
38 set(OPENMP_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}")
41 set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
42 set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
44 set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang.exe)
45 set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe)
49 # Check and set up common compiler flags.
51 include(HandleOpenMPOptions)
53 # Set up testing infrastructure.
54 include(OpenMPTesting)
56 set(OPENMP_TEST_FLAGS "" CACHE STRING
57 "Extra compiler flags to send to the test compiler.")
58 set(OPENMP_TEST_OPENMP_FLAGS ${OPENMP_TEST_COMPILER_OPENMP_FLAGS} CACHE STRING
59 "OpenMP compiler flag to use for testing OpenMP runtime libraries.")
61 set(ENABLE_LIBOMPTARGET ON)
62 # Currently libomptarget cannot be compiled on Windows or MacOS X.
63 # Since the device plugins are only supported on Linux anyway,
64 # there is no point in trying to compile libomptarget on other OSes.
65 if (APPLE OR WIN32 OR NOT OPENMP_HAVE_STD_CPP14_FLAG)
66 set(ENABLE_LIBOMPTARGET OFF)
69 set(ENABLE_LIBOMPTARGET_PROFILING OFF)
70 if (ENABLE_LIBOMPTARGET AND NOT LLVM_RUNTIMES_BUILD)
71 set(ENABLE_LIBOMPTARGET_PROFILING ON)
74 option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
75 ${ENABLE_LIBOMPTARGET})
76 option(OPENMP_ENABLE_LIBOMPTARGET_PROFILING "Enable time profiling for libomptarget."
77 ${ENABLE_LIBOMPTARGET_PROFILING})
78 option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
80 # Build host runtime library, after LIBOMPTARGET variables are set since they are needed
81 # to enable time profiling support in the OpenMP runtime.
82 add_subdirectory(runtime)
85 add_subdirectory(libompd)
87 if (OPENMP_ENABLE_LIBOMPTARGET)
88 # Check that the library can actually be built.
90 message(FATAL_ERROR "libomptarget cannot be built on Windows and MacOS X!")
91 elseif (NOT OPENMP_HAVE_STD_CPP14_FLAG)
92 message(FATAL_ERROR "Host compiler must support C++14 to build libomptarget!")
95 add_subdirectory(libomptarget)
98 set(ENABLE_OMPT_TOOLS ON)
99 # Currently tools are not tested well on Windows or MacOS X.
101 set(ENABLE_OMPT_TOOLS OFF)
104 option(OPENMP_ENABLE_OMPT_TOOLS "Enable building ompt based tools for OpenMP."
105 ${ENABLE_OMPT_TOOLS})
106 if (OPENMP_ENABLE_OMPT_TOOLS)
107 add_subdirectory(tools)
110 option(OPENMP_MSVC_NAME_SCHEME "Build dll with MSVC naming scheme." OFF)
112 # Build documentation
113 add_subdirectory(docs)
115 # Now that we have seen all testsuites, create the check-openmp target.
116 construct_check_openmp_target()