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.
This commit is contained in:
parent
9fbad8b40b
commit
f92ccbc306
@ -65,14 +65,29 @@ endmacro()
|
||||
macro(cmake_record_c_compile_features)
|
||||
set(_result 0)
|
||||
if(_result EQUAL 0 AND DEFINED CMAKE_C11_STANDARD_COMPILE_OPTION)
|
||||
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)
|
||||
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)
|
||||
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()
|
||||
|
||||
# Define to allow compile features to be automatically determined
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user