Repository navigation
CMake: let users override the macOS deployment target - #9552
Open
tautschnig wants to merge 1 commit into
Open
tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
CMakeLists.txt set CMAKE_OSX_DEPLOYMENT_TARGET as a normal variable after project(). A normal variable hides the cache entry of the same name, so neither -DCMAKE_OSX_DEPLOYMENT_TARGET=... nor the MACOSX_DEPLOYMENT_TARGET environment variable (which CMake only uses to seed that cache entry) had any effect: the hard-coded value always won. This is why the libc++ 22 build failure reported in diffblue#9489 could not be worked around without editing CMakeLists.txt, and why packagers' choice of target was silently replaced. CMake's documentation also asks for the variable to be set before the first project() call, as it is consulted while detecting the toolchain. Make 11.0 a cache default that is set before project() and only applies when neither the cache variable nor the environment variable provides a value. On macOS, project() creates an empty cache entry when neither is given, so an empty value is treated as unset (and overwritten) to keep existing build directories on 11.0 rather than the compiler's default. Also document the macOS 11.0 minimum in COMPILING.md, which never stated a minimum macOS version, and describe how to choose a newer deployment target. COMPILING.md also still suggested -DCMAKE_OSX_ARCHITECTURES=i386;x86_64 for universal binaries, which cannot work: macOS dropped 32-bit support in 10.15, and the Make build's OSX_Universal configuration already builds for arm64 and x86_64. The example was also unquoted, so a shell would treat the ";" as a command separator. Finally, "On macOS >10.14" now covers every supported macOS version, so drop the version qualifier. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
tautschnig
requested review from
a team,
kroening and
peterschrammel
as code owners
November 23, 2026 11:42
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9552 +/- ##
===========================================
- Coverage 81.28% 81.27% -0.01%
===========================================
Files 1725 1725
Lines 191618 191618
Branches 73 73
===========================================
- Hits 155751 155741 -10
- Misses 35867 35877 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CMakeLists.txt set CMAKE_OSX_DEPLOYMENT_TARGET as a normal variable after project(). A normal variable hides the cache entry of the same name, so neither -DCMAKE_OSX_DEPLOYMENT_TARGET=... nor the MACOSX_DEPLOYMENT_TARGET environment variable (which CMake only uses to seed that cache entry) had any effect: the hard-coded value always won. This is why the libc++ 22 build failure reported in #9489 could not be worked around without editing CMakeLists.txt, and why packagers' choice of target was silently replaced. CMake's documentation also asks for the variable to be set before the first project() call, as it is consulted while detecting the toolchain.
Make 11.0 a cache default that is set before project() and only applies when neither the cache variable nor the environment variable provides a value. On macOS, project() creates an empty cache entry when neither is given, so an empty value is treated as unset (and overwritten) to keep existing build directories on 11.0 rather than the compiler's default.
Also document the macOS 11.0 minimum in COMPILING.md, which never stated a minimum macOS version, and describe how to choose a newer deployment target. COMPILING.md also still suggested
-DCMAKE_OSX_ARCHITECTURES=i386;x86_64 for universal binaries, which cannot work: macOS dropped 32-bit support in 10.15, and the Make build's OSX_Universal configuration already builds for arm64 and x86_64. The example was also unquoted, so a shell would treat the ";" as a command separator. Finally, "On macOS >10.14" now covers every supported macOS version, so drop the version qualifier.