Skip to content

Conversation

@jcm93
Copy link
Contributor

@jcm93 jcm93 commented Feb 24, 2025

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 Bug Fix Non-breaking change which fixes an issue macOS Affects macOS labels Feb 26, 2025
@RytoEX RytoEX requested review from PatTheMav and gxalpha March 4, 2025 19:05
@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
Copy link
Member

@PatTheMav PatTheMav left a comment

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.

@RytoEX RytoEX merged commit 8f1bcc1 into obsproject:master Mar 31, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Fix Non-breaking change which fixes an issue macOS Affects macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants