diff options
author | Brad King <brad.king@kitware.com> | 2016-11-03 12:54:33 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-11-03 12:54:33 (GMT) |
commit | e106a6eafb42dd3c6557e964e04339dcd5787ad4 (patch) | |
tree | 930f001dd08bed13c59e2fcbe98e0c1f3cb55218 /Modules | |
parent | 90e09fb958e761b416863052ca5408ed4280443b (diff) | |
parent | 9a8d758c3a27833dccf21102ae753de314684b0d (diff) | |
download | CMake-e106a6eafb42dd3c6557e964e04339dcd5787ad4.zip CMake-e106a6eafb42dd3c6557e964e04339dcd5787ad4.tar.gz CMake-e106a6eafb42dd3c6557e964e04339dcd5787ad4.tar.bz2 |
Merge topic 'compile-features-for-language-standards'
9a8d758c Help: Document language standard meta-features
df252db1 Features: Test cycle diagnostic with language standard meta-feature
6d5fb0e0 Features: Test feature propagation with language standard meta-feature
a34b98a8 WCDH: Ignore language standard meta-features
b0996a3f Features: Add meta-features requesting awareness of a particular standard
8b6cc251 Features: Centralize per-compiler recording macros
2d23f7b2 Features: Do not record features on MSVC < 2010
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/Compiler/AppleClang-C.cmake | 10 | ||||
-rw-r--r-- | Modules/Compiler/AppleClang-CXX.cmake | 10 | ||||
-rw-r--r-- | Modules/Compiler/Clang-C.cmake | 10 | ||||
-rw-r--r-- | Modules/Compiler/Clang-CXX.cmake | 10 | ||||
-rw-r--r-- | Modules/Compiler/GNU-C.cmake | 10 | ||||
-rw-r--r-- | Modules/Compiler/GNU-CXX.cmake | 10 | ||||
-rw-r--r-- | Modules/Compiler/Intel-C.cmake | 10 | ||||
-rw-r--r-- | Modules/Compiler/Intel-CXX.cmake | 10 | ||||
-rw-r--r-- | Modules/Compiler/MSVC-CXX.cmake | 9 | ||||
-rw-r--r-- | Modules/Compiler/SunPro-CXX.cmake | 10 | ||||
-rw-r--r-- | Modules/Internal/FeatureTesting.cmake | 12 | ||||
-rw-r--r-- | Modules/WriteCompilerDetectionHeader.cmake | 7 |
12 files changed, 53 insertions, 65 deletions
diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index 1cc72c0..fe39b3b 100644 --- a/Modules/Compiler/AppleClang-C.cmake +++ b/Modules/Compiler/AppleClang-C.cmake @@ -25,18 +25,14 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) endif() macro(cmake_record_c_compile_features) - macro(_get_appleclang_features std_version list) - record_compiler_features(C "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) - _get_appleclang_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + _record_compiler_features_c(11) if (_result EQUAL 0) - _get_appleclang_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + _record_compiler_features_c(99) endif() if (_result EQUAL 0) - _get_appleclang_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + _record_compiler_features_c(90) endif() endif() endmacro() diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 95bc79a..8dd6278 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -36,21 +36,17 @@ endif() macro(cmake_record_cxx_compile_features) - macro(_get_appleclang_features std_version list) - record_compiler_features(CXX "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) set(_result 0) if(CMAKE_CXX14_STANDARD_COMPILE_OPTION) - _get_appleclang_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) + _record_compiler_features_cxx(14) endif() if (_result EQUAL 0) - _get_appleclang_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + _record_compiler_features_cxx(11) endif() if (_result EQUAL 0) - _get_appleclang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) + _record_compiler_features_cxx(98) endif() endif() endmacro() diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index d8b7743..b3f3805 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -34,18 +34,14 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) endif() macro(cmake_record_c_compile_features) - macro(_get_clang_features std_version list) - record_compiler_features(C "${std_version}" ${list}) - endmacro() - set(_result 0) if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) - _get_clang_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + _record_compiler_features_c(11) if (_result EQUAL 0) - _get_clang_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + _record_compiler_features_c(99) endif() if (_result EQUAL 0) - _get_clang_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + _record_compiler_features_c(90) endif() endif() endmacro() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index dc62711..dfe0628 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -44,18 +44,14 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) endif() macro(cmake_record_cxx_compile_features) - macro(_get_clang_features std_version list) - record_compiler_features(CXX "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) - _get_clang_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) + _record_compiler_features_cxx(14) if (_result EQUAL 0) - _get_clang_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + _record_compiler_features_cxx(11) endif() if (_result EQUAL 0) - _get_clang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) + _record_compiler_features_cxx(98) endif() endif() endmacro() diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index 2c478da..4dbf6ef 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -40,20 +40,16 @@ endif() macro(cmake_record_c_compile_features) - macro(_get_gcc_features std_version list) - record_compiler_features(C "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) - _get_gcc_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + _record_compiler_features_c(11) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) if (_result EQUAL 0) - _get_gcc_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + _record_compiler_features_c(99) endif() if (_result EQUAL 0) - _get_gcc_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + _record_compiler_features_c(90) endif() endif() endmacro() diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index e1c555b..936f62b 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -47,20 +47,16 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) endif() macro(cmake_record_cxx_compile_features) - macro(_get_gcc_features std_version list) - record_compiler_features(CXX "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) - _get_gcc_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) + _record_compiler_features_cxx(14) endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) if (_result EQUAL 0) - _get_gcc_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + _record_compiler_features_cxx(11) endif() if (_result EQUAL 0) - _get_gcc_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) + _record_compiler_features_cxx(98) endif() endif() endmacro() diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 5815857..5a79452 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -47,20 +47,16 @@ unset(_std) unset(_ext) macro(cmake_record_c_compile_features) - macro(_get_intel_c_features std_version list) - record_compiler_features(C "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) - _get_intel_c_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) + _record_compiler_features_C(11) endif() if (_result EQUAL 0) - _get_intel_c_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) + _record_compiler_features_C(99) endif() if (_result EQUAL 0) - _get_intel_c_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES) + _record_compiler_features_C(90) endif() endif() endmacro() diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index b6bc2ee..6673a2d 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -60,20 +60,16 @@ unset(_std) unset(_ext) macro(cmake_record_cxx_compile_features) - macro(_get_intel_features std_version list) - record_compiler_features(CXX "${std_version}" ${list}) - endmacro() - set(_result 0) if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0) - _get_intel_features("${CMAKE_CXX14_STANDARD_COMPILE_OPTION}" CMAKE_CXX14_COMPILE_FEATURES) + _record_compiler_features_cxx(14) endif() if (_result EQUAL 0) - _get_intel_features("${CMAKE_CXX11_STANDARD_COMPILE_OPTION}" CMAKE_CXX11_COMPILE_FEATURES) + _record_compiler_features_cxx(11) endif() if (_result EQUAL 0) - _get_intel_features("${CMAKE_CXX98_STANDARD_COMPILE_OPTION}" CMAKE_CXX98_COMPILE_FEATURES) + _record_compiler_features_cxx(98) endif() endif() endmacro() diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 82ce069..f103832 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -5,5 +5,12 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) endif() macro(cmake_record_cxx_compile_features) - record_compiler_features(CXX "" CMAKE_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 + ) + _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) + endif() endmacro() diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index ce01cdd..e83c896 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -32,6 +32,8 @@ set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_RANLIB> <TARGET> ") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") endif() @@ -49,15 +51,11 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) endif() macro(cmake_record_cxx_compile_features) - macro(_get_solaris_studio_features std_version list) - record_compiler_features(CXX "${std_version}" ${list}) - endmacro() - set(_result 0) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - _get_solaris_studio_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + _record_compiler_features_cxx(11) if (_result EQUAL 0) - _get_solaris_studio_features("" CMAKE_CXX98_COMPILE_FEATURES) + _record_compiler_features_cxx(98) endif() endif() endmacro() diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake index 86b89b2..50b8526 100644 --- a/Modules/Internal/FeatureTesting.cmake +++ b/Modules/Internal/FeatureTesting.cmake @@ -1,5 +1,5 @@ -macro(record_compiler_features lang compile_flags feature_list) +macro(_record_compiler_features lang compile_flags feature_list) include("${CMAKE_ROOT}/Modules/Compiler/${CMAKE_${lang}_COMPILER_ID}-${lang}-FeatureTests.cmake" OPTIONAL) string(TOLOWER ${lang} lang_lc) @@ -58,3 +58,13 @@ macro(record_compiler_features lang compile_flags feature_list) "Detecting ${lang} [${compile_flags}] compiler features failed to compile with the following output:\n${_output}\n${_copy_error}\n\n") endif() endmacro() + +macro(_record_compiler_features_c std) + list(APPEND CMAKE_C${std}_COMPILE_FEATURES c_std_${std}) + _record_compiler_features(C "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES) +endmacro() + +macro(_record_compiler_features_cxx std) + list(APPEND CMAKE_CXX${std}_COMPILE_FEATURES cxx_std_${std}) + _record_compiler_features(CXX "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${std}_COMPILE_FEATURES) +endmacro() diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index 82e8fba..a390f4b 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -76,6 +76,7 @@ # Available features in this version of CMake are listed in the # :prop_gbl:`CMAKE_C_KNOWN_FEATURES` and # :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global properties. +# The ``{c,cxx}_std_*`` meta-features are ignored if requested. # # See the :manual:`cmake-compile-features(7)` manual for information on # compile features. @@ -358,7 +359,11 @@ function(write_compiler_detection_header endif() foreach(feature ${_WCD_FEATURES}) - if (feature MATCHES "^cxx_") + if (feature MATCHES "^c_std_") + # ignored + elseif (feature MATCHES "^cxx_std_") + # ignored + elseif (feature MATCHES "^cxx_") list(APPEND _langs CXX) list(APPEND CXX_features ${feature}) elseif (feature MATCHES "^c_") |