mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 07:08:38 -05:00
Features: Add meta-features requesting awareness of a particular standard
A common use case of `target_compile_features` is simply to specify that the compiler should be run in a mode that is aware of e.g. C++11. Some projects simply specify a particular C++11-only feature to request this. Provide a first-class way to do this by naming features after the corresponding language standard. Record them as always available in the corresponding standard level so that requesting them always ensures that standard (or higher) is used.
This commit is contained in:
@@ -6,6 +6,11 @@ endif()
|
||||
|
||||
macro(cmake_record_cxx_compile_features)
|
||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0)
|
||||
list(APPEND CMAKE_CXX_COMPILE_FEATURES
|
||||
cxx_std_98
|
||||
cxx_std_11
|
||||
cxx_std_14
|
||||
)
|
||||
_record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -60,9 +60,11 @@ macro(_record_compiler_features lang compile_flags feature_list)
|
||||
endmacro()
|
||||
|
||||
macro(_record_compiler_features_c std)
|
||||
list(APPEND CMAKE_C${std}_COMPILE_FEATURES c_std_${std})
|
||||
_record_compiler_features(C "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES)
|
||||
endmacro()
|
||||
|
||||
macro(_record_compiler_features_cxx std)
|
||||
list(APPEND CMAKE_CXX${std}_COMPILE_FEATURES cxx_std_${std})
|
||||
_record_compiler_features(CXX "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${std}_COMPILE_FEATURES)
|
||||
endmacro()
|
||||
|
||||
Reference in New Issue
Block a user