CMake/Help/release/dev/apple-compiler-selection.rst
Brad King 7b19531291 macOS: Do not pass any SDK/-isysroot to compilers by default
On modern macOS, compiler wrappers like `/usr/bin/cc` automatically
choose a SDK to pass via `-isysroot` to an underlying compiler from
Xcode or the CommandLineTools.  Other toolchains like Homebrew's `gcc-*`
come with a default SDK too.  Therefore, when targeting macOS, we no
longer need to choose any SDK or pass an `-isysroot` flag by default.

Update initialization of `CMAKE_OSX_SYSROOT` to be empty by default when
targeting macOS.

Fixes: #19180
2024-11-07 09:46:10 -05:00

20 lines
1.1 KiB
ReStructuredText

apple-compiler-selection
------------------------
* Builds targeting macOS no longer choose any SDK or pass an ``-isysroot``
flag to the compiler by default. Instead, compilers are expected to
choose a default macOS SDK on their own. In order to use a compiler that
does not do this, users must now specify ``-DCMAKE_OSX_SYSROOT=macosx``
when configuring their build.
* On macOS with :ref:`Ninja Generators` and :ref:`Makefile Generators`, when
a compiler is found in ``/usr/bin``, it is now used as-is and is no longer
mapped to the corresponding compiler inside Xcode. The mapping was
introduced by CMake 3.2 to allow build trees to continue to work with their
original compiler even when ``xcode-select`` switches to a different
Xcode installation. However, the compilers inside Xcode cannot be used
without explicit ``-isysroot`` flags and are therefore not suitable for
passing to arbitrary third-party build systems. Furthermore, the mapping
behavior can override user-specified compiler paths. Therefore, this
behavior has been reverted.