summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2019-03-06 17:28:00 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2019-03-27 19:45:11 (GMT)
commitf92ccbc306c20554af35709faf00f402a6c34978 (patch)
tree47921cf0ad7861b50bcbc2adf2642092af94e0d3 /Modules
parent9fbad8b40be8e915f84f51842d88e97b0c949b2b (diff)
downloadCMake-f92ccbc306c20554af35709faf00f402a6c34978.zip
CMake-f92ccbc306c20554af35709faf00f402a6c34978.tar.gz
CMake-f92ccbc306c20554af35709faf00f402a6c34978.tar.bz2
CompileFeatures: memoize C compilers with full language level support
Previously compilers that had full support for a language standard level was forced to verify this every time a new build directory was created. Now we record this information and insert the correct granular compile features instead of doing a try_compile.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Compiler/CMakeCommonCompilerMacros.cmake21
-rw-r--r--Modules/Internal/FeatureTesting.cmake11
2 files changed, 29 insertions, 3 deletions
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/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()