Commit 646fb1a6 authored by Robert Maynard's avatar Robert Maynard Committed by Brad King

CompileFeatures: memoize C++ compilers with full language level support

Previously compilers that had full support for a language standard level
were still verified 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 0d641fcf
...@@ -94,18 +94,43 @@ endmacro() ...@@ -94,18 +94,43 @@ endmacro()
macro(cmake_record_cxx_compile_features) macro(cmake_record_cxx_compile_features)
set(_result 0) set(_result 0)
if(_result EQUAL 0 AND DEFINED CMAKE_CXX20_STANDARD_COMPILE_OPTION) if(_result EQUAL 0 AND DEFINED CMAKE_CXX20_STANDARD_COMPILE_OPTION)
_record_compiler_features_cxx(20) if(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT)
_has_compiler_features_cxx(20)
else()
_record_compiler_features_cxx(20)
endif()
unset(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT)
endif() endif()
if(_result EQUAL 0 AND DEFINED CMAKE_CXX17_STANDARD_COMPILE_OPTION) if(_result EQUAL 0 AND DEFINED CMAKE_CXX17_STANDARD_COMPILE_OPTION)
_record_compiler_features_cxx(17) if(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT)
_has_compiler_features_cxx(17)
else()
_record_compiler_features_cxx(17)
endif()
unset(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT)
endif() endif()
if(_result EQUAL 0 AND DEFINED CMAKE_CXX14_STANDARD_COMPILE_OPTION) if(_result EQUAL 0 AND DEFINED CMAKE_CXX14_STANDARD_COMPILE_OPTION)
_record_compiler_features_cxx(14) if(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT)
_has_compiler_features_cxx(14)
else()
_record_compiler_features_cxx(14)
endif()
unset(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT)
endif() endif()
if(_result EQUAL 0 AND DEFINED CMAKE_CXX11_STANDARD_COMPILE_OPTION) if(_result EQUAL 0 AND DEFINED CMAKE_CXX11_STANDARD_COMPILE_OPTION)
_record_compiler_features_cxx(11) if(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT)
_has_compiler_features_cxx(11)
else()
_record_compiler_features_cxx(11)
endif()
unset(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT)
endif() endif()
if(_result EQUAL 0 AND DEFINED CMAKE_CXX98_STANDARD_COMPILE_OPTION) if(_result EQUAL 0 AND DEFINED CMAKE_CXX98_STANDARD_COMPILE_OPTION)
_record_compiler_features_cxx(98) if(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT)
_has_compiler_features_cxx(98)
else()
_record_compiler_features_cxx(98)
endif()
unset(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT)
endif() endif()
endmacro() endmacro()
...@@ -99,3 +99,7 @@ macro(_has_compiler_features_c std) ...@@ -99,3 +99,7 @@ macro(_has_compiler_features_c std)
list(APPEND CMAKE_C${std}_COMPILE_FEATURES c_std_${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) _has_compiler_features(C ${std} "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES)
endmacro() endmacro()
macro(_has_compiler_features_cxx std)
list(APPEND CMAKE_CXX${std}_COMPILE_FEATURES cxx_std_${std})
_has_compiler_features(CXX ${std} "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${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