Merge topic 'xcode-macos-deployment-target'

de53a46a91 Help: Add 4.1 release note for restored Xcode default deployment target
85ba6f5d1b Merge branch 'backport-4.0-xcode-macos-deployment-target'
884260ced6 Help: Add 4.0 release note for restored Xcode default deployment target
1a37c83c7e Xcode: Restore default CMAKE_OSX_DEPLOYMENT_TARGET to run on host
e927408047 Apple: Initialize deployment target after SDK

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11361
This commit is contained in:
Brad King
2025-10-27 13:25:58 +00:00
committed by Kitware Robot
4 changed files with 92 additions and 24 deletions

View File

@@ -1,15 +1,39 @@
CMAKE_OSX_DEPLOYMENT_TARGET
---------------------------
Specify the minimum version of the target platform (e.g. macOS or iOS)
on which the target binaries are to be deployed. CMake uses this
variable value for the ``-mmacosx-version-min`` flag or their respective
target platform equivalents. For older Xcode versions that shipped
multiple macOS SDKs this variable also helps to choose the SDK in case
:variable:`CMAKE_OSX_SYSROOT` is unset.
Specify the minimum version of the target platform, e.g., macOS or iOS,
on which the target binaries are to be deployed.
If not set explicitly the value is initialized by the
``MACOSX_DEPLOYMENT_TARGET`` environment variable, if set,
and otherwise computed based on the host platform.
For builds targeting macOS (:variable:`CMAKE_SYSTEM_NAME` is ``Darwin``), if
``CMAKE_OSX_DEPLOYMENT_TARGET`` is not explicitly set, a default is set:
* If the ``MACOSX_DEPLOYMENT_TARGET`` environment variable is non-empty,
its value is the default.
* Otherwise, if using the :generator:`Xcode` generator, and the host's
macOS version is older than the macOS SDK (:variable:`CMAKE_OSX_SYSROOT`,
if set, or Xcode's default SDK), the host's macOS version is the default.
.. versionchanged:: 4.0
Previously this was done for all generators, not just Xcode.
* Otherwise, the default is empty.
The effects of ``CMAKE_OSX_DEPLOYMENT_TARGET`` depend on the generator:
:generator:`Xcode`
If ``CMAKE_OSX_DEPLOYMENT_TARGET`` is set to a non-empty value, it is added
to the generated Xcode project as the ``MACOSX_DEPLOYMENT_TARGET`` setting.
Otherwise, no such setting is added, so Xcode's default deployed target is
used, typically based on the SDK version.
Other Generators
If ``CMAKE_OSX_DEPLOYMENT_TARGET`` is set to a non-empty value, it is passed
to the compiler via the ``-mmacosx-version-min`` flag or equivalent.
Otherwise, no such flag is added, so the compiler's default deployment
target is used.
.. include:: include/CMAKE_OSX_VARIABLE.rst