summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-04-01 14:41:41 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-04-01 14:41:49 (GMT)
commitafa2614eea6571c36be130805ff876d25f3edae5 (patch)
tree30c8fe99d0eedbca31cf9353b337b7bab73f6275 /Modules
parent922480e6f14fa5b248475fb58ab07c3b2ef5befa (diff)
parent983533a4b8cc3abbeaf11c1cadad4e14dccc5824 (diff)
downloadCMake-afa2614eea6571c36be130805ff876d25f3edae5.zip
CMake-afa2614eea6571c36be130805ff876d25f3edae5.tar.gz
CMake-afa2614eea6571c36be130805ff876d25f3edae5.tar.bz2
Merge topic 'memorize_c_compilers_with_full_standard_support'
983533a4b8 Record when C compilers have gained full support for 90,99,11 f92ccbc306 CompileFeatures: memoize C compilers with full language level support Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3146
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Compiler/AppleClang-C.cmake3
-rw-r--r--Modules/Compiler/CMakeCommonCompilerMacros.cmake21
-rw-r--r--Modules/Compiler/Clang-C.cmake3
-rw-r--r--Modules/Compiler/Cray-C.cmake3
-rw-r--r--Modules/Compiler/GNU-C.cmake3
-rw-r--r--Modules/Compiler/Intel-C.cmake6
-rw-r--r--Modules/Compiler/PGI-C.cmake3
-rw-r--r--Modules/Compiler/SunPro-C.cmake3
-rw-r--r--Modules/Compiler/XL-C.cmake3
-rw-r--r--Modules/Compiler/XLClang-C.cmake3
-rw-r--r--Modules/Internal/FeatureTesting.cmake11
11 files changed, 59 insertions, 3 deletions
diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake
index a48adec..2794f52 100644
--- a/Modules/Compiler/AppleClang-C.cmake
+++ b/Modules/Compiler/AppleClang-C.cmake
@@ -4,12 +4,15 @@ __compiler_clang(C)
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
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_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
endif()
__compiler_check_default_language_standard(C 4.0 99)
diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake
index ad464c7..9c62e10 100644
--- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake
+++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake
@@ -65,13 +65,28 @@ endmacro()
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)
+ if(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_c(11)
+ else()
+ _record_compiler_features_c(11)
+ endif()
+ unset(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT)
endif()
if(_result EQUAL 0 AND DEFINED CMAKE_C99_STANDARD_COMPILE_OPTION)
- _record_compiler_features_c(99)
+ if(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_c(99)
+ else()
+ _record_compiler_features_c(99)
+ endif()
+ unset(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT)
endif()
if(_result EQUAL 0 AND DEFINED CMAKE_C90_STANDARD_COMPILE_OPTION)
- _record_compiler_features_c(90)
+ if(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_c(90)
+ else()
+ _record_compiler_features_c(90)
+ endif()
+ unset(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT)
endif()
endmacro()
diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake
index a07ae40..ff51d30 100644
--- a/Modules/Compiler/Clang-C.cmake
+++ b/Modules/Compiler/Clang-C.cmake
@@ -10,12 +10,15 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
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_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
else()
# clang-cl doesn't have any of these
set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
diff --git a/Modules/Compiler/Cray-C.cmake b/Modules/Compiler/Cray-C.cmake
index d34154c..9340948 100644
--- a/Modules/Compiler/Cray-C.cmake
+++ b/Modules/Compiler/Cray-C.cmake
@@ -10,11 +10,14 @@ string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
set(CMAKE_C90_STANDARD_COMPILE_OPTION -h noc99,conform)
set(CMAKE_C90_EXTENSION_COMPILE_OPTION -h noc99,gnu)
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
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)
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)
endif ()
endif ()
diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake
index f072c54..ca286b3 100644
--- a/Modules/Compiler/GNU-C.cmake
+++ b/Modules/Compiler/GNU-C.cmake
@@ -10,13 +10,16 @@ elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
endif()
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
endif()
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x")
diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake
index 4e4af29..e9e59a2 100644
--- a/Modules/Compiler/Intel-C.cmake
+++ b/Modules/Compiler/Intel-C.cmake
@@ -12,13 +12,16 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
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")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-Qstd=c99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-Qstd=c99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
endif()
else()
@@ -26,13 +29,16 @@ else()
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")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
endif()
endif()
diff --git a/Modules/Compiler/PGI-C.cmake b/Modules/Compiler/PGI-C.cmake
index 3b3848a..c39dbe5 100644
--- a/Modules/Compiler/PGI-C.cmake
+++ b/Modules/Compiler/PGI-C.cmake
@@ -6,11 +6,14 @@ string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10)
set(CMAKE_C90_STANDARD_COMPILE_OPTION -c89)
set(CMAKE_C90_EXTENSION_COMPILE_OPTION -c89)
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION -c99)
set(CMAKE_C99_EXTENSION_COMPILE_OPTION -c99)
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
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)
endif ()
endif ()
diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake
index c4aba8e..7e962b8 100644
--- a/Modules/Compiler/SunPro-C.cmake
+++ b/Modules/Compiler/SunPro-C.cmake
@@ -39,10 +39,13 @@ set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.13)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=c89")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=c99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=c11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
elseif (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.11)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "")
diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake
index 6fc9728..2077bda 100644
--- a/Modules/Compiler/XL-C.cmake
+++ b/Modules/Compiler/XL-C.cmake
@@ -9,11 +9,14 @@ string(APPEND CMAKE_C_FLAGS_INIT " -qthreaded")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-qlanglvl=stdc89")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-qlanglvl=extc89")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-qlanglvl=stdc99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-qlanglvl=extc99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
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)
endif ()
endif()
diff --git a/Modules/Compiler/XLClang-C.cmake b/Modules/Compiler/XLClang-C.cmake
index 8e8fcf2..54c18a6 100644
--- a/Modules/Compiler/XLClang-C.cmake
+++ b/Modules/Compiler/XLClang-C.cmake
@@ -4,13 +4,16 @@ __compiler_xlclang(C)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
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_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 ()
endif()
diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake
index b9c20ec..f7b3e96 100644
--- a/Modules/Internal/FeatureTesting.cmake
+++ b/Modules/Internal/FeatureTesting.cmake
@@ -88,3 +88,14 @@ macro(_record_compiler_features_cxx std)
endif()
unset(lang_level_has_features)
endmacro()
+
+macro(_has_compiler_features lang level compile_flags feature_list)
+ # presume all known features are supported
+ get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES)
+ list(APPEND ${feature_list} ${known_features})
+endmacro()
+
+macro(_has_compiler_features_c std)
+ list(APPEND CMAKE_C${std}_COMPILE_FEATURES c_std_${std})
+ _has_compiler_features(C ${std} "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES)
+endmacro()