Commit f92ccbc3 authored by Robert Maynard's avatar Robert Maynard

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.
parent 9fbad8b4
......@@ -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()
......
......@@ -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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment