Skip to content

Xcode: Fix detection of default language standard when given -std= flags

Brad King requested to merge brad.king/cmake:xcode-lang-defaults into master

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 !6177 (merged), 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.

Merge request reports