mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-18 13:10:17 -06:00
Xcode: Fix detection of default language standard when given -std= flags
If one uses `CFLAGS='-std=...'` or `CXXFLAGS='-std=...'` then the given
`-std=` flag(s) will always be used. That effectively changes the
compiler default standard level and extension settings. Fix the
Xcode generator's compiler id logic to preserve any `-std=` flag
so that the proper defaults are detected.
This problem was exposed by commit 4a0485be7f (cmStandardLevelResolver:
Avoid unnecessary flags, fix unset level logic, 2021-05-29), which
changed the logic to not pass any `-std=` flag if the standard level
and extension settings requested by the project match the default
(`stdIt <= defaultStdIt` became `stdIt < defaultStdIt`). The new
logic assumes the detected default standard matches what will actually
happen when the project is generated.
This commit is contained in:
@@ -539,6 +539,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
|
||||
else()
|
||||
set(id_toolset "")
|
||||
endif()
|
||||
set(id_lang_version "")
|
||||
if("x${lang}" STREQUAL "xSwift")
|
||||
if(CMAKE_Swift_LANGUAGE_VERSION)
|
||||
set(id_lang_version "SWIFT_VERSION = ${CMAKE_Swift_LANGUAGE_VERSION};")
|
||||
@@ -549,8 +550,14 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
|
||||
else()
|
||||
set(id_lang_version "SWIFT_VERSION = 2.3;")
|
||||
endif()
|
||||
else()
|
||||
set(id_lang_version "")
|
||||
elseif("x${lang}" STREQUAL "xC" OR "x${lang}" STREQUAL "xOBJC")
|
||||
if(CMAKE_${lang}_COMPILER_ID_FLAGS MATCHES "(^| )(-std=[^ ]+)( |$)")
|
||||
set(id_lang_version "OTHER_CFLAGS = \"${CMAKE_MATCH_2}\";")
|
||||
endif()
|
||||
elseif("x${lang}" STREQUAL "xCXX" OR "x${lang}" STREQUAL "xOBJCXX")
|
||||
if(CMAKE_${lang}_COMPILER_ID_FLAGS MATCHES "(^| )(-std=[^ ]+)( |$)")
|
||||
set(id_lang_version "OTHER_CPLUSPLUSFLAGS = \"${CMAKE_MATCH_2}\";")
|
||||
endif()
|
||||
endif()
|
||||
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
set(id_deployment_target
|
||||
|
||||
Reference in New Issue
Block a user