cmake: Adjust macOS SDK detection #11893
Open
+16
−2
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.
Description
Adjust the macOS CMake initialization logic to use
xcrun
to derive our SDK version information, rather than relying on the presence of${CMAKE_OSX_SYSROOT}
.Motivation and Context
CMake 4.0.0 (currently in the release candidate phase) breaks OBS configuration/generation on macOS. This is because CMake 4.0.0 no longer defines
CMAKE_OSX_SYSROOT
by default for macOS builds, which we currently rely on to make sure the user has an SDK supported by OBS.This CMake change was apparently made because specifying
CMAKE_OSX_SYSROOT
seems to translate under the hood to passing-isysroot
to the compiler, which apparently had some undesired impacts in some situations (further context here and here). Letting the compiler wrapper figure out its sysroot on its own seems to now be the preferred pattern.As we would still like to check what SDK version the user has installed, we can just derive it ourselves using
xcrun
to populate a variable with the user's environment's currently configured SDK path. This way we can make sure that the user has an SDK version we support, while still letting CMake not define a sysroot.How Has This Been Tested?
Installed CMake 4.0.0 rc1 and configured/generated/built OBS successfully; also made sure configuration/generation/building proceeded successfully on CMake 3.31.4.
Types of changes
Checklist: