mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
The changes are part of CMP0128. When the standard level is unset: * Flags are added if extension mode doesn't match the compiler's default. Previously logic only worked if LANG_EXTENSIONS was ON. Fixes #22224. * The full flag is used. Previously CMAKE_LANG_EXTENSION_COMPILE_OPTION was used. This was only supported for IAR. Otherwise: * Avoid adding flags if not necessary per the detected compiler defaults. * Fixed check for when the requested standard is older. It now matches the nearby comments. I reworded the fallback comment as its logic was a bit difficult to wrap my head around.
39 lines
935 B
CMake
39 lines
935 B
CMake
enable_language(C CXX)
|
|
|
|
set(info "")
|
|
|
|
if(MSVC_TOOLSET_VERSION)
|
|
string(APPEND info "
|
|
set(MSVC_TOOLSET_VERSION ${MSVC_TOOLSET_VERSION})
|
|
|
|
")
|
|
endif()
|
|
|
|
if(CMAKE_XCODE_BUILD_SYSTEM)
|
|
string(APPEND info "
|
|
set(CMAKE_XCODE_BUILD_SYSTEM ${CMAKE_XCODE_BUILD_SYSTEM})
|
|
|
|
")
|
|
endif()
|
|
|
|
macro(info lang)
|
|
string(APPEND info "\
|
|
set(${lang}_STANDARD_DEFAULT ${CMAKE_${lang}_STANDARD_DEFAULT})
|
|
set(${lang}_EXTENSIONS_DEFAULT ${CMAKE_${lang}_EXTENSIONS_DEFAULT})
|
|
set(${lang}_FEATURES ${CMAKE_${lang}_COMPILE_FEATURES})
|
|
|
|
set(${lang}_EXT_FLAG ${CMAKE_${lang}_EXTENSION_COMPILE_OPTION})
|
|
")
|
|
|
|
foreach(standard ${ARGN})
|
|
string(APPEND info "\
|
|
set(${lang}${standard}_FLAG ${CMAKE_${lang}${standard}_STANDARD_COMPILE_OPTION})
|
|
set(${lang}${standard}_EXT_FLAG ${CMAKE_${lang}${standard}_EXTENSION_COMPILE_OPTION})
|
|
")
|
|
endforeach()
|
|
endmacro()
|
|
|
|
info(C 90 99 11 17 23)
|
|
info(CXX 98 11 14 17 20 23)
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}")
|