diff options
author | Tyler <tylerbrawl@gmail.com> | 2024-03-20 21:54:36 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-04-30 15:05:03 (GMT) |
commit | 7c38e6bb526ceb6a678497aaeb1e6076f7a38ba3 (patch) | |
tree | 6840245e6e62a3ba2b75504c90d78facfdb20f90 /Modules/Compiler | |
parent | fddb165c6ce9483e1b928de2eaff3e93464b7f04 (diff) | |
download | CMake-7c38e6bb526ceb6a678497aaeb1e6076f7a38ba3.zip CMake-7c38e6bb526ceb6a678497aaeb1e6076f7a38ba3.tar.gz CMake-7c38e6bb526ceb6a678497aaeb1e6076f7a38ba3.tar.bz2 |
Add CMAKE_<LANG>_STANDARD_LATEST variables
Add a variable to indicate the latest standard known to be supported for
each language:
* `CMAKE_C_STANDARD_LATEST`
* `CMAKE_CXX_STANDARD_LATEST`
* `CMAKE_CUDA_STANDARD_LATEST`
* `CMAKE_HIP_STANDARD_LATEST`
* `CMAKE_OBJC_STANDARD_LATEST`
* `CMAKE_OBJCXX_STANDARD_LATEST`
These variables, more generally referred to as
`CMAKE_<LANG>_STANDARD_LATEST`, are assigned an integer value which
represents the minimum between the latest version of the associated
language standard supported by the current compiler and the latest
version supported by CMake.
Add documentation for these variables in a new page called
`CMAKE_<LANG>_STANDARD_LATEST` was added under the "Variables for
Languages" section of the `cmake-variables(7)` page.
Update each compiler-specific CMake script under
`${CMAKE_ROOT}\Modules\Compiler` to manually define the relevant
`CMAKE_<LANG>_STANDARD_LATEST` variable as necessary. This will
require updating and maintaining as newer compiler versions become
recognized by CMake.
Closes: #25717
Diffstat (limited to 'Modules/Compiler')
48 files changed, 274 insertions, 50 deletions
diff --git a/Modules/Compiler/ADSP-C.cmake b/Modules/Compiler/ADSP-C.cmake index cef3fb1..1898401 100644 --- a/Modules/Compiler/ADSP-C.cmake +++ b/Modules/Compiler/ADSP-C.cmake @@ -8,4 +8,6 @@ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C_STANDARD_LATEST 99) + __compiler_check_default_language_standard(C 8.0.0.0 99) diff --git a/Modules/Compiler/ADSP-CXX.cmake b/Modules/Compiler/ADSP-CXX.cmake index b01cab1..e82d9fb 100644 --- a/Modules/Compiler/ADSP-CXX.cmake +++ b/Modules/Compiler/ADSP-CXX.cmake @@ -6,11 +6,13 @@ __compiler_adsp(CXX) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -c++) set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -g++) set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_CXX_STANDARD_LATEST 98) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.3.0.0) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -c++11) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -c++11 -g++) set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 11) endif() __compiler_check_default_language_standard(CXX 8.0.0.0 98) diff --git a/Modules/Compiler/ARMClang-C.cmake b/Modules/Compiler/ARMClang-C.cmake index 643fdad..fce1a8e 100644 --- a/Modules/Compiler/ARMClang-C.cmake +++ b/Modules/Compiler/ARMClang-C.cmake @@ -22,6 +22,8 @@ set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C_STANDARD_LATEST 11) + # Including the "${CMAKE_ROOT}/Modules/Compiler/Clang-C.cmake" script above may set several other compile option # variables which do not necessarily apply here. So, we unset those variables accordingly. unset(CMAKE_C17_STANDARD_COMPILE_OPTION) diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index d711b6e..41e7988 100644 --- a/Modules/Compiler/AppleClang-C.cmake +++ b/Modules/Compiler/AppleClang-C.cmake @@ -26,16 +26,20 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_C_STANDARD_LATEST 11) endif() if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0) set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std=c17") set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std=gnu17") + set(CMAKE_C_STANDARD_LATEST 17) endif() if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0.3) set(CMAKE_C23_STANDARD_COMPILE_OPTION "-std=c2x") set(CMAKE_C23_EXTENSION_COMPILE_OPTION "-std=gnu2x") + set(CMAKE_C_STANDARD_LATEST 23) endif() __compiler_check_default_language_standard(C 4.0 99 9.1 11 12.0.5 17) diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 7c97969..8a6c855 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -22,25 +22,31 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + + set(CMAKE_CXX_STANDARD_LATEST 11) endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 14) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) # AppleClang 5.0 knows this flag, but does not set a __cplusplus macro greater than 201103L set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 14) endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") + set(CMAKE_CXX_STANDARD_LATEST 17) elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") + set(CMAKE_CXX_STANDARD_LATEST 17) endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) @@ -50,14 +56,17 @@ endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++20") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20") + set(CMAKE_CXX_STANDARD_LATEST 20) elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") + set(CMAKE_CXX_STANDARD_LATEST 20) endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) set(CMAKE_CXX23_STANDARD_COMPILE_OPTION "-std=c++2b") set(CMAKE_CXX23_EXTENSION_COMPILE_OPTION "-std=gnu++2b") + set(CMAKE_CXX_STANDARD_LATEST 23) endif() __compiler_check_default_language_standard(CXX 4.0 98) diff --git a/Modules/Compiler/AppleClang-OBJC.cmake b/Modules/Compiler/AppleClang-OBJC.cmake index 8a95d26..aa02d4b 100644 --- a/Modules/Compiler/AppleClang-OBJC.cmake +++ b/Modules/Compiler/AppleClang-OBJC.cmake @@ -21,6 +21,8 @@ if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 4.0) set(CMAKE_OBJC11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_OBJC11_EXTENSION_COMPILE_OPTION "-std=gnu11") set(CMAKE_OBJC11_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJC_STANDARD_LATEST 11) endif() # AppleClang 10.0 was the oldest compiler available to test C17 support @@ -28,12 +30,16 @@ if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 10.0) set(CMAKE_OBJC17_STANDARD_COMPILE_OPTION "-std=c17") set(CMAKE_OBJC17_EXTENSION_COMPILE_OPTION "-std=gnu17") set(CMAKE_OBJC17_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJC_STANDARD_LATEST 17) endif() if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 11.0.3) set(CMAKE_OBJC23_STANDARD_COMPILE_OPTION "-std=c2x") set(CMAKE_OBJC23_EXTENSION_COMPILE_OPTION "-std=gnu2x") set(CMAKE_OBJC23_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJC_STANDARD_LATEST 23) endif() # AppleClang 10.0 was the oldest compiler available to test default C11 support diff --git a/Modules/Compiler/AppleClang-OBJCXX.cmake b/Modules/Compiler/AppleClang-OBJCXX.cmake index 172a343..d2573e5 100644 --- a/Modules/Compiler/AppleClang-OBJCXX.cmake +++ b/Modules/Compiler/AppleClang-OBJCXX.cmake @@ -19,25 +19,31 @@ if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 4.0) set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + + set(CMAKE_OBJCXX_STANDARD_LATEST 11) endif() if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 6.1) set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_OBJCXX_STANDARD_LATEST 14) elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 5.1) # AppleClang 5.0 knows this flag, but does not set a __cplusplus macro greater than 201103L set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++1y") set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_OBJCXX_STANDARD_LATEST 14) endif() if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 10.0) set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") + set(CMAKE_OBJCXX_STANDARD_LATEST 17) elseif (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 6.1) set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++1z") set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") + set(CMAKE_OBJCXX_STANDARD_LATEST 17) endif() if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 8.0) @@ -47,6 +53,7 @@ endif() if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 10.0) set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std=c++2a") set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") + set(CMAKE_OBJCXX_STANDARD_LATEST 20) endif() __compiler_check_default_language_standard(OBJCXX 4.0 98) diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index 480a5de..c9b1669 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -33,27 +33,34 @@ if("x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + + set(CMAKE_C_STANDARD_LATEST 99) endif() if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.1) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C_STANDARD_LATEST 11) elseif(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x") + set(CMAKE_C_STANDARD_LATEST 11) endif() if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0) set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std=c17") set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std=gnu17") + set(CMAKE_C_STANDARD_LATEST 17) endif() if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 18.0) set(CMAKE_C23_STANDARD_COMPILE_OPTION "-std=c23") set(CMAKE_C23_EXTENSION_COMPILE_OPTION "-std=gnu23") + set(CMAKE_C_STANDARD_LATEST 23) elseif(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0) set(CMAKE_C23_STANDARD_COMPILE_OPTION "-std=c2x") set(CMAKE_C23_EXTENSION_COMPILE_OPTION "-std=gnu2x") + set(CMAKE_C_STANDARD_LATEST 23) endif() else() set(CMAKE_C90_STANDARD_COMPILE_OPTION "") @@ -74,6 +81,8 @@ else() set(CMAKE_C17_STANDARD_COMPILE_OPTION "") set(CMAKE_C17_EXTENSION_COMPILE_OPTION "") endif() + + set(CMAKE_C_STANDARD_LATEST 17) endif() if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 2.1) diff --git a/Modules/Compiler/Clang-OBJC.cmake b/Modules/Compiler/Clang-OBJC.cmake index 7a83b77..c374d71 100644 --- a/Modules/Compiler/Clang-OBJC.cmake +++ b/Modules/Compiler/Clang-OBJC.cmake @@ -22,18 +22,24 @@ if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 3.4) set(CMAKE_OBJC11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_OBJC11_EXTENSION_COMPILE_OPTION "-std=gnu11") set(CMAKE_OBJC11_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJC_STANDARD_LATEST 11) endif() if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 6.0) set(CMAKE_OBJC17_STANDARD_COMPILE_OPTION "-std=c17") set(CMAKE_OBJC17_EXTENSION_COMPILE_OPTION "-std=gnu17") set(CMAKE_OBJC17_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJC_STANDARD_LATEST 17) endif() if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 9.0) set(CMAKE_OBJC23_STANDARD_COMPILE_OPTION "-std=c2x") set(CMAKE_OBJC23_EXTENSION_COMPILE_OPTION "-std=gnu2x") set(CMAKE_OBJC23_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJC_STANDARD_LATEST 23) endif() __compiler_check_default_language_standard(OBJC 3.4 99 3.6 11) diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index 2452d5e..089b188 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -135,6 +135,7 @@ macro(__compiler_clang_cxx_standards lang) if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 2.1) set(CMAKE_${lang}98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_${lang}98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + set(CMAKE_${lang}_STANDARD_LATEST 98) endif() if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.1) @@ -142,19 +143,23 @@ macro(__compiler_clang_cxx_standards lang) set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=gnu++11") set(CMAKE_${lang}11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_${lang}_STANDARD_LATEST 11) elseif(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 2.1) set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c++0x") set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") + set(CMAKE_${lang}_STANDARD_LATEST 11) endif() if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.5) set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "-std=gnu++14") set(CMAKE_${lang}14_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_${lang}_STANDARD_LATEST 14) elseif(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4) set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std=c++1y") set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") set(CMAKE_${lang}14_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_${lang}_STANDARD_LATEST 14) endif() set(_clang_version_std17 5.0) @@ -165,17 +170,21 @@ macro(__compiler_clang_cxx_standards lang) if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}") set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=gnu++17") + set(CMAKE_${lang}_STANDARD_LATEST 17) elseif (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.5) set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c++1z") set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") + set(CMAKE_${lang}_STANDARD_LATEST 17) endif() if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 11.0) set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++20") set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=gnu++20") + set(CMAKE_${lang}_STANDARD_LATEST 20) elseif(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}") set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++2a") set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") + set(CMAKE_${lang}_STANDARD_LATEST 20) endif() unset(_clang_version_std17) @@ -190,9 +199,11 @@ macro(__compiler_clang_cxx_standards lang) set(CMAKE_${lang}23_EXTENSION_COMPILE_OPTION "-std=gnu++23") set(CMAKE_${lang}26_STANDARD_COMPILE_OPTION "-std=c++26") set(CMAKE_${lang}26_EXTENSION_COMPILE_OPTION "-std=gnu++26") + set(CMAKE_${lang}_STANDARD_LATEST 26) elseif(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_${lang}23_STANDARD_COMPILE_OPTION "-std=c++2b") set(CMAKE_${lang}23_EXTENSION_COMPILE_OPTION "-std=gnu++2b") + set(CMAKE_${lang}_STANDARD_LATEST 23) endif() unset(_clang_version_std23) @@ -231,14 +242,18 @@ macro(__compiler_clang_cxx_standards lang) set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std:c++latest") endif() + set(CMAKE_${lang}_STANDARD_LATEST 17) + if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0) set(CMAKE_${lang}23_STANDARD_COMPILE_OPTION "-std:c++latest") set(CMAKE_${lang}23_EXTENSION_COMPILE_OPTION "-std:c++latest") set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std:c++20") set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std:c++20") + set(CMAKE_${lang}_STANDARD_LATEST 23) elseif(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0) set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std:c++latest") set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std:c++latest") + set(CMAKE_${lang}_STANDARD_LATEST 20) endif() __compiler_check_default_language_standard(${lang} 3.9 14) @@ -262,6 +277,14 @@ macro(__compiler_clang_cxx_standards lang) # There is no meaningful default for this set(CMAKE_${lang}_STANDARD_DEFAULT "") + if(CMAKE_${lang}_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0) + set(CMAKE_${lang}_STANDARD_LATEST 17) + elseif(CMAKE_${lang}_SIMULATE_VERSION VERSION_GREATER_EQUAL 18.0) + set(CMAKE_${lang}_STANDARD_LATEST 14) + elseif(CMAKE_${lang}_SIMULATE_VERSION VERSION_GREATER_EQUAL 16.0) + set(CMAKE_${lang}_STANDARD_LATEST 11) + endif() + # There are no compiler modes so we only need to test features once. # Override the default macro for this special case. Pretend that # all language standards are available so that at least compilation diff --git a/Modules/Compiler/Cray-C.cmake b/Modules/Compiler/Cray-C.cmake index 9340948..51f8cc4 100644 --- a/Modules/Compiler/Cray-C.cmake +++ b/Modules/Compiler/Cray-C.cmake @@ -14,10 +14,12 @@ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) set(CMAKE_C99_STANDARD_COMPILE_OPTION -h c99,conform) set(CMAKE_C99_EXTENSION_COMPILE_OPTION -h c99,gnu) set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C_STANDARD_LATEST 99) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.5) set(CMAKE_C11_STANDARD_COMPILE_OPTION -h std=c11,conform) set(CMAKE_C11_EXTENSION_COMPILE_OPTION -h std=c11,gnu) set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C_STANDARD_LATEST 11) endif () endif () diff --git a/Modules/Compiler/Cray-CXX.cmake b/Modules/Compiler/Cray-CXX.cmake index 38c8b1e..9a40b98 100644 --- a/Modules/Compiler/Cray-CXX.cmake +++ b/Modules/Compiler/Cray-CXX.cmake @@ -11,15 +11,18 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -h conform) set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -h gnu) set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 98) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.4) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -h std=c++11) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -h std=c++11,gnu) set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 11) endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.6) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION -h std=c++14) set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -h std=c++14,gnu) set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 14) endif () endif () diff --git a/Modules/Compiler/CrayClang-C.cmake b/Modules/Compiler/CrayClang-C.cmake index bf878fc..96e46be 100644 --- a/Modules/Compiler/CrayClang-C.cmake +++ b/Modules/Compiler/CrayClang-C.cmake @@ -27,4 +27,6 @@ set(CMAKE_C17_EXTENSION_COMPILE_OPTION -std=gnu17) set(CMAKE_C23_STANDARD_COMPILE_OPTION -std=c2x) set(CMAKE_C23_EXTENSION_COMPILE_OPTION -std=gnu2x) +set(CMAKE_C_STANDARD_LATEST 23) + __compiler_check_default_language_standard(C 15.0.0 17) diff --git a/Modules/Compiler/CrayClang-CXX.cmake b/Modules/Compiler/CrayClang-CXX.cmake index de6a53c..a61edfa 100644 --- a/Modules/Compiler/CrayClang-CXX.cmake +++ b/Modules/Compiler/CrayClang-CXX.cmake @@ -32,4 +32,6 @@ set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION -std=gnu++20) set(CMAKE_CXX23_STANDARD_COMPILE_OPTION -std=c++2b) set(CMAKE_CXX23_EXTENSION_COMPILE_OPTION -std=gnu++2b) +set(CMAKE_CXX_STANDARD_LATEST 23) + __compiler_check_default_language_standard(CXX 15.0.0 14) diff --git a/Modules/Compiler/Fujitsu-C.cmake b/Modules/Compiler/Fujitsu-C.cmake index dd31e43..0ffa82d 100644 --- a/Modules/Compiler/Fujitsu-C.cmake +++ b/Modules/Compiler/Fujitsu-C.cmake @@ -15,6 +15,8 @@ if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4) set(CMAKE_C11_STANDARD_COMPILE_OPTION -std=c11) set(CMAKE_C11_EXTENSION_COMPILE_OPTION -std=gnu11) set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_C_STANDARD_LATEST 11) endif() __compiler_check_default_language_standard(C 4 11) diff --git a/Modules/Compiler/Fujitsu-CXX.cmake b/Modules/Compiler/Fujitsu-CXX.cmake index 0f42196..56f16c1 100644 --- a/Modules/Compiler/Fujitsu-CXX.cmake +++ b/Modules/Compiler/Fujitsu-CXX.cmake @@ -42,6 +42,8 @@ if(CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 4) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION -std=c++17) set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION -std=gnu++17) + + set(CMAKE_CXX_STANDARD_LATEST 17) endif() __compiler_check_default_language_standard(CXX 4 14) diff --git a/Modules/Compiler/GNU-OBJC.cmake b/Modules/Compiler/GNU-OBJC.cmake index 7eeed83..4a2cd85 100644 --- a/Modules/Compiler/GNU-OBJC.cmake +++ b/Modules/Compiler/GNU-OBJC.cmake @@ -1,5 +1,6 @@ include(Compiler/GNU) __compiler_gnu(OBJC) +__compiler_gnu_c_standards(OBJC) if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) diff --git a/Modules/Compiler/GNU-OBJCXX.cmake b/Modules/Compiler/GNU-OBJCXX.cmake index 1047b5d..e3006f2 100644 --- a/Modules/Compiler/GNU-OBJCXX.cmake +++ b/Modules/Compiler/GNU-OBJCXX.cmake @@ -1,5 +1,6 @@ include(Compiler/GNU) __compiler_gnu(OBJCXX) +__compiler_gnu_cxx_standards(OBJCXX) if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 857399c..3f705a9 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -212,9 +212,11 @@ macro(__compiler_gnu_c_standards lang) if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.5) set(CMAKE_${lang}90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_${lang}90_EXTENSION_COMPILE_OPTION "-std=gnu90") + set(CMAKE_${lang}_STANDARD_LATEST 90) elseif (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4) set(CMAKE_${lang}90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_${lang}90_EXTENSION_COMPILE_OPTION "-std=gnu89") + set(CMAKE_${lang}_STANDARD_LATEST 90) endif() if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4) @@ -222,25 +224,30 @@ macro(__compiler_gnu_c_standards lang) set(CMAKE_${lang}99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_${lang}99_EXTENSION_COMPILE_OPTION "-std=gnu99") set(CMAKE_${lang}99_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_${lang}_STANDARD_LATEST 99) endif() if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.7) set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=gnu11") set(CMAKE_${lang}11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_${lang}_STANDARD_LATEST 11) elseif (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.6) set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c1x") set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=gnu1x") + set(CMAKE_${lang}_STANDARD_LATEST 11) endif() if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c17") set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=gnu17") + set(CMAKE_${lang}_STANDARD_LATEST 17) endif() if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 9.1) set(CMAKE_${lang}23_STANDARD_COMPILE_OPTION "-std=c2x") set(CMAKE_${lang}23_EXTENSION_COMPILE_OPTION "-std=gnu2x") + set(CMAKE_${lang}_STANDARD_LATEST 23) endif() endmacro() @@ -248,16 +255,19 @@ macro(__compiler_gnu_cxx_standards lang) if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4) set(CMAKE_${lang}98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_${lang}98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + set(CMAKE_${lang}_STANDARD_LATEST 98) endif() if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.7) set(CMAKE_${lang}98_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + set(CMAKE_${lang}_STANDARD_LATEST 11) elseif (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.4) # 4.3 supports 0x variants set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c++0x") set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") + set(CMAKE_${lang}_STANDARD_LATEST 11) endif() if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.8.1) @@ -267,9 +277,11 @@ macro(__compiler_gnu_cxx_standards lang) if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.9) set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "-std=gnu++14") + set(CMAKE_${lang}_STANDARD_LATEST 14) elseif (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.8) set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std=c++1y") set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") + set(CMAKE_${lang}_STANDARD_LATEST 14) endif() if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 5.0) @@ -279,9 +291,11 @@ macro(__compiler_gnu_cxx_standards lang) if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 8.0) set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=gnu++17") + set(CMAKE_${lang}_STANDARD_LATEST 17) elseif (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 5.1) set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c++1z") set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") + set(CMAKE_${lang}_STANDARD_LATEST 17) endif() if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 11.1) @@ -289,13 +303,16 @@ macro(__compiler_gnu_cxx_standards lang) set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=gnu++20") set(CMAKE_${lang}23_STANDARD_COMPILE_OPTION "-std=c++23") set(CMAKE_${lang}23_EXTENSION_COMPILE_OPTION "-std=gnu++23") + set(CMAKE_${lang}_STANDARD_LATEST 23) elseif(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++2a") set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") + set(CMAKE_${lang}_STANDARD_LATEST 20) endif() if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0) set(CMAKE_${lang}26_STANDARD_COMPILE_OPTION "-std=c++26") set(CMAKE_${lang}26_EXTENSION_COMPILE_OPTION "-std=gnu++26") + set(CMAKE_${lang}_STANDARD_LATEST 26) endif() endmacro() diff --git a/Modules/Compiler/IBMClang-C.cmake b/Modules/Compiler/IBMClang-C.cmake index b69b1b8..fde6a3b 100644 --- a/Modules/Compiler/IBMClang-C.cmake +++ b/Modules/Compiler/IBMClang-C.cmake @@ -23,8 +23,11 @@ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") +set(CMAKE_C_STANDARD_LATEST 11) + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 17.1.0) set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std=c17") set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std=gnu17") + set(CMAKE_C_STANDARD_LATEST 17) endif () __compiler_check_default_language_standard(C 17.1.0 17) diff --git a/Modules/Compiler/IBMClang-CXX.cmake b/Modules/Compiler/IBMClang-CXX.cmake index be9b525..ec97381 100644 --- a/Modules/Compiler/IBMClang-CXX.cmake +++ b/Modules/Compiler/IBMClang-CXX.cmake @@ -26,6 +26,8 @@ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") +set(CMAKE_CXX_STANDARD_LATEST 14) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.1.0) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") @@ -33,6 +35,7 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.1.0) set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20") set(CMAKE_CXX23_STANDARD_COMPILE_OPTION "-std=c++2b") set(CMAKE_CXX23_EXTENSION_COMPILE_OPTION "-std=gnu++2b") + set(CMAKE_CXX_STANDARD_LATEST 23) endif() __compiler_check_default_language_standard(CXX 17.1.0 17) diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 9884b58..bfe5f07 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -19,12 +19,6 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_C_CLANG_TIDY_DRIVER_MODE "cl") set(CMAKE_C_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 16.0.0) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "-Qstd=c11") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-Qstd=c11") - set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) - endif() - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-Qstd=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-Qstd=c89") @@ -32,18 +26,20 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_C99_STANDARD_COMPILE_OPTION "-Qstd=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-Qstd=c99") set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C_STANDARD_LATEST 99) + endif() + + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 16.0.0) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-Qstd=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-Qstd=c11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C_STANDARD_LATEST 11) endif() else() set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") - set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) - endif() - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") @@ -51,6 +47,14 @@ else() set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C_STANDARD_LATEST 99) + endif() + + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C_STANDARD_LATEST 11) endif() endif() diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index 7666b2d..f9e3e7a 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -18,57 +18,70 @@ if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CXX_CLANG_TIDY_DRIVER_MODE "cl") set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE_DRIVER_MODE "cl") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.0) - set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-Qstd=c++20") - set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-Qstd=c++20") - endif() + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.0) - set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-Qstd=c++17") - set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-Qstd=c++17") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-Qstd=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-Qstd=c++11") + else() + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-Qstd=c++0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-Qstd=c++0x") + endif() + + set(CMAKE_CXX_STANDARD_LATEST 11) endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-Qstd=c++14") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-Qstd=c++14") + set(CMAKE_CXX_STANDARD_LATEST 14) endif() - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-Qstd=c++11") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-Qstd=c++11") - elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-Qstd=c++0x") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-Qstd=c++0x") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.0) + set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-Qstd=c++17") + set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-Qstd=c++17") + set(CMAKE_CXX_STANDARD_LATEST 17) endif() - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") - set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.0) + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-Qstd=c++20") + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-Qstd=c++20") + set(CMAKE_CXX_STANDARD_LATEST 20) endif() else() set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.0.20190206) - set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++20") - set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20") - endif() + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.0) - set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") - set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + else() + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") + endif() + + set(CMAKE_CXX_STANDARD_LATEST 11) endif() - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0) - set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0) + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.2) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") + set(CMAKE_CXX_STANDARD_LATEST 14) elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.0) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") + set(CMAKE_CXX_STANDARD_LATEST 14) endif() # Intel 15.0.2 accepts c++14 instead of c++1y, but not gnu++14 @@ -79,22 +92,20 @@ else() set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") endif() - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0) - set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0) + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) endif() - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") - elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.0) + set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") + set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") + set(CMAKE_CXX_STANDARD_LATEST 17) endif() - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") - set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.0.20190206) + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++20") + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20") + set(CMAKE_CXX_STANDARD_LATEST 20) endif() endif() diff --git a/Modules/Compiler/IntelLLVM-C.cmake b/Modules/Compiler/IntelLLVM-C.cmake index f783d81..4da4dfb 100644 --- a/Modules/Compiler/IntelLLVM-C.cmake +++ b/Modules/Compiler/IntelLLVM-C.cmake @@ -42,9 +42,12 @@ if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std=c17") set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std=gnu17") + set(CMAKE_C_STANDARD_LATEST 17) + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 2022.1.0) set(CMAKE_C23_STANDARD_COMPILE_OPTION "-std=c2x") set(CMAKE_C23_EXTENSION_COMPILE_OPTION "-std=gnu2x") + set(CMAKE_C_STANDARD_LATEST 23) endif() else() set(CMAKE_C90_STANDARD_COMPILE_OPTION "-Qstd:c90") @@ -59,9 +62,12 @@ else() set(CMAKE_C17_STANDARD_COMPILE_OPTION "-Qstd:c17") set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-Qstd:c17") + set(CMAKE_C_STANDARD_LATEST 17) + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 2022.1.0) set(CMAKE_C23_STANDARD_COMPILE_OPTION "-Qstd:c2x") set(CMAKE_C23_EXTENSION_COMPILE_OPTION "-Qstd:c2x") + set(CMAKE_C_STANDARD_LATEST 23) endif() endif() diff --git a/Modules/Compiler/IntelLLVM-CXX.cmake b/Modules/Compiler/IntelLLVM-CXX.cmake index bd92139..989a1d4 100644 --- a/Modules/Compiler/IntelLLVM-CXX.cmake +++ b/Modules/Compiler/IntelLLVM-CXX.cmake @@ -47,9 +47,12 @@ if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++20") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20") + set(CMAKE_CXX_STANDARD_LATEST 20) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2021.2.0) set(CMAKE_CXX23_STANDARD_COMPILE_OPTION "-std=c++2b") set(CMAKE_CXX23_EXTENSION_COMPILE_OPTION "-std=gnu++2b") + set(CMAKE_CXX_STANDARD_LATEST 23) endif() else() set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") @@ -67,9 +70,12 @@ else() set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-Qstd:c++20") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-Qstd:c++20") + set(CMAKE_CXX_STANDARD_LATEST 20) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 2021.2.0) set(CMAKE_CXX23_STANDARD_COMPILE_OPTION "-Qstd:c++2b") set(CMAKE_CXX23_EXTENSION_COMPILE_OPTION "-Qstd:c++2b") + set(CMAKE_CXX_STANDARD_LATEST 23) endif() endif() diff --git a/Modules/Compiler/LCC-C.cmake b/Modules/Compiler/LCC-C.cmake index 52c3bf3..01e99d3 100644 --- a/Modules/Compiler/LCC-C.cmake +++ b/Modules/Compiler/LCC-C.cmake @@ -22,15 +22,19 @@ set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C_STANDARD_LATEST 99) + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 1.20) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C_STANDARD_LATEST 11) endif() if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 1.26) set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std=c17") set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std=gnu17") + set(CMAKE_C_STANDARD_LATEST 17) endif() __compiler_check_default_language_standard(C 1.17 89 1.23 99 1.26 17) diff --git a/Modules/Compiler/LCC-CXX.cmake b/Modules/Compiler/LCC-CXX.cmake index 385947a..22f2cc3 100644 --- a/Modules/Compiler/LCC-CXX.cmake +++ b/Modules/Compiler/LCC-CXX.cmake @@ -18,26 +18,32 @@ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_CXX_STANDARD_LATEST 98) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 1.20) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 11) endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 1.21) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 14) endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 1.24) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") + set(CMAKE_CXX_STANDARD_LATEST 17) endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 1.26) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") + set(CMAKE_CXX_STANDARD_LATEST 20) endif() __compiler_check_default_language_standard(CXX 1.19 98 1.20 11 1.21 14 1.24 17 1.26 20) diff --git a/Modules/Compiler/MSVC-C.cmake b/Modules/Compiler/MSVC-C.cmake index 6bf6b4e..d7fbf9f 100644 --- a/Modules/Compiler/MSVC-C.cmake +++ b/Modules/Compiler/MSVC-C.cmake @@ -14,12 +14,15 @@ if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std:c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std:c11") + set(CMAKE_C_STANDARD_LATEST 11) + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.28) set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std:c17") set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std:c17") + set(CMAKE_C_STANDARD_LATEST 17) else() # Special case for 19.27 (VS 16.7): C11 has partial support. macro(cmake_record_c_compile_features) @@ -41,6 +44,7 @@ else() set(CMAKE_C99_EXTENSION_COMPILE_OPTION "") set(CMAKE_C11_STANDARD_COMPILE_OPTION "") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "") + set(CMAKE_C_STANDARD_LATEST 11) # There is no meaningful default for this set(CMAKE_C_STANDARD_DEFAULT "") diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 79cd2e0..2243a14 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -30,14 +30,18 @@ if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std:c++latest") endif() + set(CMAKE_CXX_STANDARD_LATEST 17) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30129) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std:c++20") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std:c++20") set(CMAKE_CXX23_STANDARD_COMPILE_OPTION "-std:c++latest") set(CMAKE_CXX23_EXTENSION_COMPILE_OPTION "-std:c++latest") + set(CMAKE_CXX_STANDARD_LATEST 23) elseif(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") + set(CMAKE_CXX_STANDARD_LATEST 20) endif() __compiler_check_default_language_standard(CXX 19.0 14) @@ -57,6 +61,14 @@ elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "") + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0) + set(CMAKE_CXX_STANDARD_LATEST 17) + elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18.0) + set(CMAKE_CXX_STANDARD_LATEST 14) + else() + set(CMAKE_CXX_STANDARD_LATEST 11) + endif() + # There is no meaningful default for this set(CMAKE_CXX_STANDARD_DEFAULT "") diff --git a/Modules/Compiler/NVHPC-C.cmake b/Modules/Compiler/NVHPC-C.cmake index 9295abd..3838ebd 100644 --- a/Modules/Compiler/NVHPC-C.cmake +++ b/Modules/Compiler/NVHPC-C.cmake @@ -7,6 +7,7 @@ set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 20.11) set(CMAKE_C17_STANDARD_COMPILE_OPTION -std=c17) set(CMAKE_C17_EXTENSION_COMPILE_OPTION -std=gnu17) + set(CMAKE_C_STANDARD_LATEST 17) endif() if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 21.07) diff --git a/Modules/Compiler/NVHPC-CXX.cmake b/Modules/Compiler/NVHPC-CXX.cmake index 59ba7bf..0d804f4 100644 --- a/Modules/Compiler/NVHPC-CXX.cmake +++ b/Modules/Compiler/NVHPC-CXX.cmake @@ -7,6 +7,7 @@ set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20.11) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION -std=c++20) set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION -std=gnu++20) + set(CMAKE_CXX_STANDARD_LATEST 20) endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 21.07) diff --git a/Modules/Compiler/NVIDIA.cmake b/Modules/Compiler/NVIDIA.cmake index a126c57..21e71cc 100644 --- a/Modules/Compiler/NVIDIA.cmake +++ b/Modules/Compiler/NVIDIA.cmake @@ -17,6 +17,8 @@ macro(__compiler_nvidia_cxx_standards lang) set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "") set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "") + set(CMAKE_${lang}_STANDARD_LATEST 11) + if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 9.0) if(CMAKE_${lang}_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.10.25017) set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std=c++14") @@ -25,12 +27,15 @@ macro(__compiler_nvidia_cxx_standards lang) set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "") set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "") endif() + + set(CMAKE_${lang}_STANDARD_LATEST 14) endif() if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 11.0) if(CMAKE_${lang}_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.11.25505) set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=c++17") + set(CMAKE_${lang}_STANDARD_LATEST 17) endif() endif() @@ -38,6 +43,7 @@ macro(__compiler_nvidia_cxx_standards lang) if(CMAKE_${lang}_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.11.25505) set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++20") set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=c++20") + set(CMAKE_${lang}_STANDARD_LATEST 20) endif() endif() else() @@ -47,21 +53,27 @@ macro(__compiler_nvidia_cxx_standards lang) set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=c++11") + set(CMAKE_${lang}_STANDARD_LATEST 11) + if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 9.0) set(CMAKE_${lang}03_STANDARD_COMPILE_OPTION "-std=c++03") set(CMAKE_${lang}03_EXTENSION_COMPILE_OPTION "-std=c++03") set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "-std=c++14") + + set(CMAKE_${lang}_STANDARD_LATEST 14) endif() if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 11.0) set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=c++17") + set(CMAKE_${lang}_STANDARD_LATEST 17) endif() if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++20") set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=c++20") + set(CMAKE_${lang}_STANDARD_LATEST 20) endif() endif() diff --git a/Modules/Compiler/OrangeC-C.cmake b/Modules/Compiler/OrangeC-C.cmake index 15a6476..f0dfcd1 100644 --- a/Modules/Compiler/OrangeC-C.cmake +++ b/Modules/Compiler/OrangeC-C.cmake @@ -15,6 +15,8 @@ set(CMAKE_C11_STANDARD_COMPILE_OPTION -std=c11) set(CMAKE_C11_EXTENSION_COMPILE_OPTION -std=c11) set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C_STANDARD_LATEST 11) + __compiler_orangec(C) #- 6.38 is the earliest version which version info is available in the preprocessor __compiler_check_default_language_standard(C 6.38 11) diff --git a/Modules/Compiler/OrangeC-CXX.cmake b/Modules/Compiler/OrangeC-CXX.cmake index 3f9d59c..575c09d 100644 --- a/Modules/Compiler/OrangeC-CXX.cmake +++ b/Modules/Compiler/OrangeC-CXX.cmake @@ -20,6 +20,8 @@ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=c++14") set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_CXX_STANDARD_LATEST 14) + __compiler_orangec(CXX) #- 6.38 is the earliest version which version info is available in the preprocessor __compiler_check_default_language_standard(CXX 6.38 14) diff --git a/Modules/Compiler/PGI-C.cmake b/Modules/Compiler/PGI-C.cmake index c39dbe5..798fc84 100644 --- a/Modules/Compiler/PGI-C.cmake +++ b/Modules/Compiler/PGI-C.cmake @@ -10,10 +10,13 @@ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10) set(CMAKE_C99_STANDARD_COMPILE_OPTION -c99) set(CMAKE_C99_EXTENSION_COMPILE_OPTION -c99) set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_C_STANDARD_LATEST 99) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15.3) set(CMAKE_C11_STANDARD_COMPILE_OPTION -c11) set(CMAKE_C11_EXTENSION_COMPILE_OPTION -c11) set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C_STANDARD_LATEST 11) endif () endif () diff --git a/Modules/Compiler/PGI-CXX.cmake b/Modules/Compiler/PGI-CXX.cmake index 1279c19..972e43a 100644 --- a/Modules/Compiler/PGI-CXX.cmake +++ b/Modules/Compiler/PGI-CXX.cmake @@ -7,19 +7,23 @@ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION --gnu_extensions) set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 98) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.10) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION --c++03) set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION --c++03 --gnu_extensions) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION --c++11) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION --c++11 --gnu_extensions) set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 11) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.7) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14) set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION --c++14 --gnu_extensions) set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 14) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.1) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION --c++17) set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION --c++17 --gnu_extensions) + set(CMAKE_CXX_STANDARD_LATEST 17) endif() endif() endif() diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index b06719d..7b4478c 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -52,11 +52,15 @@ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.13) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=c11") set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_C_STANDARD_LATEST 11) elseif (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.11) set(CMAKE_C90_STANDARD_COMPILE_OPTION "") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "") set(CMAKE_C99_STANDARD_COMPILE_OPTION "-xc99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-xc99") + + set(CMAKE_C_STANDARD_LATEST 99) endif() __compiler_check_default_language_standard(C 5.11 90 5.14 11) diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index f835f2d..1db6aa7 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -54,14 +54,18 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX_LINK_WITH_STANDARD_COMPILE_OPTION 1) + set(CMAKE_CXX_STANDARD_LATEST 11) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=c++14") + set(CMAKE_CXX_STANDARD_LATEST 14) endif() else() set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-library=stlport4") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-library=stlport4") set(CMAKE_CXX_LINK_WITH_STANDARD_COMPILE_OPTION 1) + set(CMAKE_CXX_STANDARD_LATEST 98) endif() __compiler_check_default_language_standard(CXX 1 98) diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake index bd88989..7f3b67c 100644 --- a/Modules/Compiler/TI-C.cmake +++ b/Modules/Compiler/TI-C.cmake @@ -34,18 +34,23 @@ if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_C99_VERSION_$ set(CMAKE_C99_STANDARD_COMPILE_OPTION "--c99" "--strict_ansi") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--c99" "--relaxed_ansi") + set(CMAKE_C_STANDARD_LATEST 99) + if(DEFINED __COMPILER_TI_C11_VERSION_${CMAKE_C_COMPILER_ARCHITECTURE_ID} AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_C11_VERSION_${CMAKE_C_COMPILER_ARCHITECTURE_ID}}") set(CMAKE_C11_STANDARD_COMPILE_OPTION "--c11" "--strict_ansi") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "--c11" "--relaxed_ansi") + set(CMAKE_C_STANDARD_LATEST 11) + endif() else() set(CMAKE_C90_STANDARD_COMPILE_OPTION "--strict_ansi") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--relaxed_ansi") + set(CMAKE_C_STANDARD_LATEST 90) endif() diff --git a/Modules/Compiler/TI-CXX.cmake b/Modules/Compiler/TI-CXX.cmake index 4b6efcd..c904239 100644 --- a/Modules/Compiler/TI-CXX.cmake +++ b/Modules/Compiler/TI-CXX.cmake @@ -39,16 +39,19 @@ if(DEFINED __COMPILER_TI_CXX14_VERSION AND set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "--c++14" "--strict_ansi") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "--c++14" "--relaxed_ansi") + set(CMAKE_CXX_STANDARD_LATEST 14) elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "${__COMPILER_TI_CXX03_VERSION}") set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "--c++03" "--strict_ansi") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "--c++03" "--relaxed_ansi") + set(CMAKE_CXX_STANDARD_LATEST 98) else() set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "--strict_ansi") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "--relaxed_ansi") + set(CMAKE_CXX_STANDARD_LATEST 98) endif() diff --git a/Modules/Compiler/TIClang-C.cmake b/Modules/Compiler/TIClang-C.cmake index 30e6b5d..b6ce3dc 100644 --- a/Modules/Compiler/TIClang-C.cmake +++ b/Modules/Compiler/TIClang-C.cmake @@ -22,6 +22,8 @@ set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) +set(CMAKE_C_STANDARD_LATEST 11) + # Including the "${CMAKE_ROOT}/Modules/Compiler/Clang-C.cmake" script above may set several other compile option # variables which do not necessarily apply here. So, we unset those variables accordingly. unset(CMAKE_C17_STANDARD_COMPILE_OPTION) diff --git a/Modules/Compiler/TIClang-CXX.cmake b/Modules/Compiler/TIClang-CXX.cmake index 4fb2d70..e1367df 100644 --- a/Modules/Compiler/TIClang-CXX.cmake +++ b/Modules/Compiler/TIClang-CXX.cmake @@ -24,6 +24,8 @@ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") +set(CMAKE_CXX_STANDARD_LATEST 17) + # Including the "${CMAKE_ROOT}/Modules/Compiler/Clang-CXX.cmake" script above may set several other compile option # variables which do not necessarily apply here. So, we unset those variables accordingly. unset(CMAKE_CXX20_STANDARD_COMPILE_OPTION) diff --git a/Modules/Compiler/Tasking-C.cmake b/Modules/Compiler/Tasking-C.cmake index 0ea3cd2..938f46e 100644 --- a/Modules/Compiler/Tasking-C.cmake +++ b/Modules/Compiler/Tasking-C.cmake @@ -10,6 +10,8 @@ set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--iso=99" " ") set(CMAKE_C11_STANDARD_COMPILE_OPTION "--iso=11" "--strict") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "--iso=11" " ") +set(CMAKE_C_STANDARD_LATEST 11) + if(CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "TriCore") if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") __compiler_check_default_language_standard(C 10.1 11) diff --git a/Modules/Compiler/Tasking-CXX.cmake b/Modules/Compiler/Tasking-CXX.cmake index 635104c..20e007f 100644 --- a/Modules/Compiler/Tasking-CXX.cmake +++ b/Modules/Compiler/Tasking-CXX.cmake @@ -12,6 +12,8 @@ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "--c++=11" " ") set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "--c++=14" "--strict") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "--c++=14" " ") +set(CMAKE_CXX_STANDARD_LATEST 14) + if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "TriCore") if(CMAKE_TASKING_TOOLSET STREQUAL "SmartCode") __compiler_check_default_language_standard(CXX 10.1 14) diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake index 2077bda..d14ac85 100644 --- a/Modules/Compiler/XL-C.cmake +++ b/Modules/Compiler/XL-C.cmake @@ -13,10 +13,13 @@ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-qlanglvl=stdc99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-qlanglvl=extc99") set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_C_STANDARD_LATEST 99) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.1) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x") set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C_STANDARD_LATEST 11) endif () endif() diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake index 41e3e11..57bd5a9 100644 --- a/Modules/Compiler/XL-CXX.cmake +++ b/Modules/Compiler/XL-CXX.cmake @@ -24,10 +24,13 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) # compiler mode for the corresponding standard. set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 11) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.1.0 AND CMAKE_SYSTEM_NAME STREQUAL "Linux") set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-qlanglvl=extended1y") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-qlanglvl=extended1y") set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX_STANDARD_LATEST 14) endif() endif () diff --git a/Modules/Compiler/XLClang-C.cmake b/Modules/Compiler/XLClang-C.cmake index 1668a4d..7ca76e4 100644 --- a/Modules/Compiler/XLClang-C.cmake +++ b/Modules/Compiler/XLClang-C.cmake @@ -12,11 +12,14 @@ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x") + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif () + + set(CMAKE_C_STANDARD_LATEST 11) endif() __compiler_check_default_language_standard(C 13.1.1 99) diff --git a/Modules/Compiler/XLClang-CXX.cmake b/Modules/Compiler/XLClang-CXX.cmake index 02638c7..b324987 100644 --- a/Modules/Compiler/XLClang-CXX.cmake +++ b/Modules/Compiler/XLClang-CXX.cmake @@ -10,12 +10,17 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x") set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_CXX_STANDARD_LATEST 11) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_CXX_STANDARD_LATEST 14) endif () if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.1.0) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") |