Resolve "Apple Clang for Xcode 10.0 not supported with MACOSX_DEPLOYMENT_TARGET=10.7"
This PR is split into two commits. The first one adds support for the CMAKE_CXX_STDLIB
variable. Dependent on the Xcode version that variable can be left empty to select the compiler default or set to either libc++
or libstdc++
. It is then applied to both the Xcode project settings and the architecture flags.
I chose to introduce the CMAKE_CXX_STDLIB
setting because I did not know if changing CMAKE_CXX_FLAGS(_INIT)
within Modules/Platform/Apple-AppleClang-CXX.cmake
would be a good idea. Having an extra variable also ensures that I can forward the setting to try_compile
unconditionally whereas the CXX_FLAGS
forwarding code seems to be dependent on a policy.
The second commit sets the CMAKE_CXX_STDLIB
flag to libc++
if AppleClang >= 10 is detected. Starting with Xcode 10 the GNU libstdc++ C++ runtime has been removed. Deployment targets that would have autoselected libstdc++ with Xcode 9 now emit the error message to migrate to libstdc++ instead of also defaulting to libstdc++.
Please review the changes. If you're OK with the changes I'll add documentation and a test.
Thanks, Gregor
Closes #18396 (closed)