diff options
author | Brad King <brad.king@kitware.com> | 2017-06-01 17:40:03 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-06-01 17:40:47 (GMT) |
commit | 860db083cafb1337147923f7dd21b57767abbee3 (patch) | |
tree | fea1a13e782087d9699998de11a2f321769c2103 /Modules | |
parent | c80148c77e552a43b0648bad02de86e6b6d2b61d (diff) | |
parent | 3c1ecb5214afa45a44742ad2b1e24517925e858a (diff) | |
download | CMake-860db083cafb1337147923f7dd21b57767abbee3.zip CMake-860db083cafb1337147923f7dd21b57767abbee3.tar.gz CMake-860db083cafb1337147923f7dd21b57767abbee3.tar.bz2 |
Merge topic 'add-common-record-features-macros'
3c1ecb52 Intel: Fix missing C std default for 12.0 <= ver < 12.1
f70b0bb3 SunPro: Make sure all known versions get CXX98 defaults
220ede74 GNU: Fix language defaults for 3.4
a40e6ba8 Clang: Fix language defaults for 2.1
9b112a84 Compilers: Port to use default cmake_record_lang_compile_features macros
37221529 MSVC: Add empty definitions for std compile options
e556f1b9 CompileFeatures: Makes tests work with meta-feature only
20ffa147 Tests: Allow test macro to take no executable arguments
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !833
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/Compiler/AppleClang-C.cmake | 15 | ||||
-rw-r--r-- | Modules/Compiler/AppleClang-CXX.cmake | 18 | ||||
-rw-r--r-- | Modules/Compiler/CMakeCommonCompilerMacros.cmake | 31 | ||||
-rw-r--r-- | Modules/Compiler/Clang-C.cmake | 15 | ||||
-rw-r--r-- | Modules/Compiler/Clang-CXX.cmake | 20 | ||||
-rw-r--r-- | Modules/Compiler/GNU-C.cmake | 15 | ||||
-rw-r--r-- | Modules/Compiler/GNU-CXX.cmake | 20 | ||||
-rw-r--r-- | Modules/Compiler/Intel-C.cmake | 17 | ||||
-rw-r--r-- | Modules/Compiler/Intel-CXX.cmake | 18 | ||||
-rw-r--r-- | Modules/Compiler/MSVC-CXX.cmake | 32 | ||||
-rw-r--r-- | Modules/Compiler/SunPro-C.cmake | 15 | ||||
-rw-r--r-- | Modules/Compiler/SunPro-CXX.cmake | 18 |
12 files changed, 55 insertions, 179 deletions
diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index c18f541..a48adec 100644 --- a/Modules/Compiler/AppleClang-C.cmake +++ b/Modules/Compiler/AppleClang-C.cmake @@ -13,18 +13,3 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) endif() __compiler_check_default_language_standard(C 4.0 99) - -macro(cmake_record_c_compile_features) - set(_result 0) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) - if (_result EQUAL 0) - _record_compiler_features_c(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(99) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(90) - endif() - endif() -endmacro() diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 904d965..e5fd647 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -28,21 +28,3 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1) endif() __compiler_check_default_language_standard(CXX 4.0 98) - -macro(cmake_record_cxx_compile_features) - set(_result 0) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) - if(_result EQUAL 0 AND CMAKE_CXX17_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(17) - endif() - if(_result EQUAL 0 AND CMAKE_CXX14_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(14) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(98) - endif() - endif() -endmacro() diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index cb365d6..684fd30 100644 --- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake +++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake @@ -60,3 +60,34 @@ macro(__compiler_check_default_language_standard lang stdver1 std1) endif () unset(__std_ver_pairs) endmacro() + +# Define to allow compile features to be automatically determined +macro(cmake_record_c_compile_features) + set(_result 0) + if(_result EQUAL 0 AND DEFINED CMAKE_C11_STANDARD_COMPILE_OPTION) + _record_compiler_features_c(11) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_C99_STANDARD_COMPILE_OPTION) + _record_compiler_features_c(99) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_C90_STANDARD_COMPILE_OPTION) + _record_compiler_features_c(90) + endif() +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_CXX17_STANDARD_COMPILE_OPTION) + _record_compiler_features_cxx(17) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CXX14_STANDARD_COMPILE_OPTION) + _record_compiler_features_cxx(14) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CXX11_STANDARD_COMPILE_OPTION) + _record_compiler_features_cxx(11) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CXX98_STANDARD_COMPILE_OPTION) + _record_compiler_features_cxx(98) + endif() +endmacro() diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index b94087f..b881e2b 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -18,18 +18,3 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) endif() __compiler_check_default_language_standard(C 3.4 99 3.6 11) - -macro(cmake_record_c_compile_features) - set(_result 0) - if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) - if (_result EQUAL 0) - _record_compiler_features_c(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(99) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(90) - endif() - endif() -endmacro() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 5904efa..d3707ee 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -36,22 +36,4 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") endif() -__compiler_check_default_language_standard(CXX 3.1 98) - -macro(cmake_record_cxx_compile_features) - set(_result 0) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1) - if(_result EQUAL 0 AND CMAKE_CXX17_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(17) - endif() - if(_result EQUAL 0 AND CMAKE_CXX14_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(14) - endif() - if (_result EQUAL 0 AND CMAKE_CXX11_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(98) - endif() - endif() -endmacro() +__compiler_check_default_language_standard(CXX 2.1 98) diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index 8090fa6..f072c54 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -23,18 +23,3 @@ elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) endif() __compiler_check_default_language_standard(C 3.4 90 5.0 11) - -macro(cmake_record_c_compile_features) - set(_result 0) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) - if(_result EQUAL 0 AND CMAKE_C11_STANDARD_COMPILE_OPTION) - _record_compiler_features_c(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(99) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(90) - endif() - endif() -endmacro() diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index b221c4a..4f1f30e 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -38,22 +38,4 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") endif() -__compiler_check_default_language_standard(CXX 4.4 98 6.0 14) - -macro(cmake_record_cxx_compile_features) - set(_result 0) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) - if(_result EQUAL 0 AND CMAKE_CXX17_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(17) - endif() - if(_result EQUAL 0 AND CMAKE_CXX14_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(14) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(98) - endif() - endif() -endmacro() +__compiler_check_default_language_standard(CXX 3.4 98 6.0 14) diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 20e29e2..4e4af29 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -37,22 +37,7 @@ else() endif() -__compiler_check_default_language_standard(C 12.1 90 15.0.0 11) - -macro(cmake_record_c_compile_features) - set(_result 0) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1) - if (_result EQUAL 0 AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) - _record_compiler_features_C(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_C(99) - endif() - if (_result EQUAL 0) - _record_compiler_features_C(90) - endif() - endif() -endmacro() +__compiler_check_default_language_standard(C 12.0 90 15.0.0 11) set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index 08d23fc..0eb9e1f 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -56,23 +56,5 @@ endif() __compiler_check_default_language_standard(CXX 12.1 98) -macro(cmake_record_cxx_compile_features) - set(_result 0) - if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) - if (_result EQUAL 0 AND - (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0 - OR (NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" AND - NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0))) - _record_compiler_features_cxx(14) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(98) - endif() - endif() -endmacro() - set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 8fcfa0f..9371301 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -1,17 +1,21 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. -if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) - # MSVC has no specific language level or flags to change it. +include(Compiler/CMakeCommonCompilerMacros) + +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) + # MSVC has no specific options to set language standards, but set them as + # empty strings anyways so the feature test infrastructure can at least check + # to see if they are defined. + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "") + + # There is no meaningful default for this set(CMAKE_CXX_STANDARD_DEFAULT "") endif() - -macro(cmake_record_cxx_compile_features) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) - list(APPEND CMAKE_CXX_COMPILE_FEATURES - cxx_std_98 - cxx_std_11 - cxx_std_14 - cxx_std_17 - ) - _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) - endif() -endmacro() diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index ac88e6f..29c2f22 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -43,20 +43,5 @@ endif() __compiler_check_default_language_standard(C 5.11 90 5.14 11) -macro(cmake_record_c_compile_features) - set(_result 0) - if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.13) - if(_result EQUAL 0 AND CMAKE_C11_STANDARD_COMPILE_OPTION) - _record_compiler_features_c(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(99) - endif() - if (_result EQUAL 0) - _record_compiler_features_c(90) - endif() - endif() -endmacro() - set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 4b0a21d..5cb7edc 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -43,21 +43,9 @@ 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) else() - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-library=stlport") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-library=stlport") + 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) endif() -__compiler_check_default_language_standard(CXX 5.13 98) - -macro(cmake_record_cxx_compile_features) - set(_result 0) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - if (_result EQUAL 0) - _record_compiler_features_cxx(11) - endif() - if (_result EQUAL 0) - _record_compiler_features_cxx(98) - endif() - endif() -endmacro() +__compiler_check_default_language_standard(CXX 1 98) |