Skip to content

cmake: Adjust macOS SDK detection#11893

Merged
RytoEX merged 1 commit into
obsproject:masterfrom
jcm93:fix/mac-sdk
Mar 31, 2025
Merged

cmake: Adjust macOS SDK detection#11893
RytoEX merged 1 commit into
obsproject:masterfrom
jcm93:fix/mac-sdk

Conversation

@jcm93

@jcm93 jcm93 commented Feb 24, 2025

Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@jcm93 jcm93 changed the title build: Adjust macOS SDK detection cmake: Adjust macOS SDK detection Feb 24, 2025
@WizardCM WizardCM added kind/bug Categorizes issue or PR as related to a bug. platform/macos Categorizes issue or PR as affecting macOS specifically labels Feb 26, 2025
Comment thread cmake/macos/compilerconfig.cmake Outdated
@RytoEX
RytoEX requested a review from PatTheMav March 13, 2025 01:58
@jcm93
jcm93 force-pushed the fix/mac-sdk branch 4 times, most recently from 8404301 to 858a72c Compare March 15, 2025 05:42
Comment thread cmake/macos/compilerconfig.cmake Outdated

@PatTheMav PatTheMav left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me - errors for missing Xcode installation or missing versions are correctly caught and appropriate error messages shown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. platform/macos Categorizes issue or PR as affecting macOS specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants