summaryrefslogtreecommitdiff
path: root/openmp/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'openmp/CMakeLists.txt')
-rw-r--r--openmp/CMakeLists.txt14
1 files changed, 12 insertions, 2 deletions
diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index 50246b663289..9f989266d6ae 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -37,6 +37,10 @@ if (OPENMP_STANDALONE_BUILD)
set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING
"C++ compiler to use for testing OpenMP runtime libraries.")
set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.")
+
+ set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
+ set(CMAKE_CXX_STANDARD_REQUIRED NO)
+ set(CMAKE_CXX_EXTENSIONS NO)
else()
set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR})
# If building in tree, we honor the same install suffix LLVM uses.
@@ -49,6 +53,12 @@ else()
set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang.exe)
set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe)
endif()
+
+ # If not standalone, set CMAKE_CXX_STANDARD but don't set the global cache value,
+ # only set it locally for OpenMP.
+ set(CMAKE_CXX_STANDARD 17)
+ set(CMAKE_CXX_STANDARD_REQUIRED NO)
+ set(CMAKE_CXX_EXTENSIONS NO)
endif()
# Check and set up common compiler flags.
@@ -68,7 +78,7 @@ set(ENABLE_LIBOMPTARGET ON)
# Since the device plugins are only supported on Linux anyway,
# there is no point in trying to compile libomptarget on other OSes.
# 32-bit systems are not supported either.
-if (APPLE OR WIN32 OR NOT OPENMP_HAVE_STD_CPP17_FLAG OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
+if (APPLE OR WIN32 OR NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ENABLE_LIBOMPTARGET OFF)
endif()
@@ -92,7 +102,7 @@ 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_CPP17_FLAG)
+ elseif (NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
message(FATAL_ERROR "Host compiler must support C++17 to build libomptarget!")
elseif (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
message(FATAL_ERROR "libomptarget on 32-bit systems are not supported!")