summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-12-06 11:06:12 -0500
committerBrad King <brad.king@kitware.com>2017-12-22 09:05:54 -0500
commit31d59ff3b104f012d5eca9e15c1558e2c67ef495 (patch)
tree6ed1348bc8805a0d13b202768a88fc6c0e23b5a5 /CMakeLists.txt
parent31c6b9adbff0fd7113ce4b97bc4ad9514615deb8 (diff)
downloadcmake-31d59ff3b104f012d5eca9e15c1558e2c67ef495.tar.gz
Compile CMake as C++17 if supported by the compiler
Add a check that a simple source file can compile as C++17 that uses some of the features we need. Do this only when hosted by CMake 3.8 or above because those versions are aware of C++17. Check for unordered_map as we do in bootstrap since commit 375eca7881 (bootstrap: Check support for unordered_map from compiler mode, 2017-11-30). Also maintain the existing C++14 cstdio check.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt17
1 files changed, 13 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 945ae8d22d..e4d2a9a0a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,11 +64,20 @@ if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD)
if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14)
set(CMAKE_CXX_STANDARD 98)
else()
- include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx14_check.cmake)
- if(NOT CMake_CXX14_BROKEN)
- set(CMAKE_CXX_STANDARD 14)
+ if(NOT CMAKE_VERSION VERSION_LESS 3.8)
+ include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx17_check.cmake)
else()
- set(CMAKE_CXX_STANDARD 11)
+ set(CMake_CXX17_BROKEN 1)
+ endif()
+ if(NOT CMake_CXX17_BROKEN)
+ set(CMAKE_CXX_STANDARD 17)
+ else()
+ include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx14_check.cmake)
+ if(NOT CMake_CXX14_BROKEN)
+ set(CMAKE_CXX_STANDARD 14)
+ else()
+ set(CMAKE_CXX_STANDARD 11)
+ endif()
endif()
endif()
endif()