diff options
author | Brad King <brad.king@kitware.com> | 2018-04-02 14:00:00 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-04-02 14:01:23 (GMT) |
commit | 1b6ec4b9e34a06c047cb41245587673959b5b591 (patch) | |
tree | 4945534c7f8b71ea81c4a9c708e2531d907e275c /Modules/Compiler | |
parent | 5d5e1e691772ecfd9224be0afe33802f8aee3fc3 (diff) | |
parent | 8570dc7f64928ec7896197394f089f5ad063c6ca (diff) | |
download | CMake-1b6ec4b9e34a06c047cb41245587673959b5b591.zip CMake-1b6ec4b9e34a06c047cb41245587673959b5b591.tar.gz CMake-1b6ec4b9e34a06c047cb41245587673959b5b591.tar.bz2 |
Merge topic 'features-c++20'
8570dc7f64 Help: Update compiler versions in cmake-compile-features.7.rst
874d3d2948 Help: Add release note for C++ 20 support
7f295b1bd3 Features: Activate C++ 20 support for Clang 5.0+
71cb8ce3a1 Features: Activate C++ 20 support for GNU 8.0+
8f146c4508 Features: Activate C++ 20 support for MSVC 19.12.25835+
7fe580a362 Features: Add infrastructure for C++ 20 language standard
1b328e09a3 Features: Use -std=c++17 for C++ 17 on Clang 5.0+
0bc3e5788a Features: Use -std=c++17 for C++ 17 on GNU 8.0+
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1892
Diffstat (limited to 'Modules/Compiler')
-rw-r--r-- | Modules/Compiler/CMakeCommonCompilerMacros.cmake | 3 | ||||
-rw-r--r-- | Modules/Compiler/Clang-CXX.cmake | 12 | ||||
-rw-r--r-- | Modules/Compiler/GNU-CXX.cmake | 10 | ||||
-rw-r--r-- | Modules/Compiler/MSVC-CXX.cmake | 13 |
4 files changed, 36 insertions, 2 deletions
diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index 684fd30..ad464c7 100644 --- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake +++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake @@ -78,6 +78,9 @@ endmacro() # Define to allow compile features to be automatically determined macro(cmake_record_cxx_compile_features) set(_result 0) + if(_result EQUAL 0 AND DEFINED CMAKE_CXX20_STANDARD_COMPILE_OPTION) + _record_compiler_features_cxx(20) + endif() if(_result EQUAL 0 AND DEFINED CMAKE_CXX17_STANDARD_COMPILE_OPTION) _record_compiler_features_cxx(17) endif() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index efc68b3..321ddf6 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -32,10 +32,18 @@ if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") endif() - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") + set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") + elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") endif() + + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") + endif() else() # clang-cl does not know these options because it behaves like cl.exe set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") @@ -46,6 +54,8 @@ else() set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "") set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "") endif() if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 4f1f30e..0058223 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -33,9 +33,17 @@ elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") endif() -if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) + set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") + set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") +elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") endif() +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") +endif() + __compiler_check_default_language_standard(CXX 3.4 98 6.0 14) diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 789fff5..be259ff 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -22,6 +22,10 @@ if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std:c++latest") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std:c++latest") endif() + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.12.25835) + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std:c++latest") + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std:c++latest") + endif() __compiler_check_default_language_standard(CXX 19.0 14) @@ -29,6 +33,12 @@ if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND # for meta-features for C++14 and above. Override the default macro # to avoid doing unnecessary work. macro(cmake_record_cxx_compile_features) + if (DEFINED CMAKE_CXX20_STANDARD_COMPILE_OPTION) + list(APPEND CMAKE_CXX20_COMPILE_FEATURES cxx_std_20) + endif() + # The main cmake_record_cxx_compile_features macro makes all + # these conditional on CMAKE_CXX##_STANDARD_COMPILE_OPTION, + # but we can skip the conditions because we set them above. list(APPEND CMAKE_CXX17_COMPILE_FEATURES cxx_std_17) list(APPEND CMAKE_CXX14_COMPILE_FEATURES cxx_std_14) list(APPEND CMAKE_CXX98_COMPILE_FEATURES cxx_std_11) # no flag needed for 11 @@ -46,6 +56,8 @@ elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "") set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "") # There is no meaningful default for this set(CMAKE_CXX_STANDARD_DEFAULT "") @@ -60,6 +72,7 @@ elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) cxx_std_11 cxx_std_14 cxx_std_17 + cxx_std_20 ) _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) endmacro() |