Skip to content

CMake: respect externally-set CMAKE_OSX_SYSROOT on macOS (v2-3)#570

Draft
taylorhoward92 wants to merge 1 commit intoOGRECave:v2-3from
taylorhoward92:fix/cmake-osx-sysroot-v2-3
Draft

CMake: respect externally-set CMAKE_OSX_SYSROOT on macOS (v2-3)#570
taylorhoward92 wants to merge 1 commit intoOGRECave:v2-3from
taylorhoward92:fix/cmake-osx-sysroot-v2-3

Conversation

@taylorhoward92
Copy link
Copy Markdown

Summary

The macOS (non-iOS) build section unconditionally sets
CMAKE_OSX_SYSROOT via xcodebuild -version -sdk (Unix Makefiles)
or set(CMAKE_OSX_SYSROOT macosx) (other generators). This overrides
any externally-provided sysroot, breaking builds that need a specific
SDK path (package managers like Nix/Homebrew, cross-compilation setups).

Changes

Wrap the CMAKE_OSX_SYSROOT assignments in if(NOT CMAKE_OSX_SYSROOT)
so auto-detection only runs when no sysroot has been set externally.

set(XCODE_ATTRIBUTE_SDKROOT macosx) is left outside the guard — it's
a non-harmful Xcode project attribute that doesn't affect the actual
SDK path resolution.

Test plan

  • Build on macOS without setting CMAKE_OSX_SYSROOT — auto-detection
    runs as before (no behavior change)
  • Build on macOS with -DCMAKE_OSX_SYSROOT=/path/to/sdk — the
    provided value is respected

The macOS build section unconditionally overrides CMAKE_OSX_SYSROOT,
either via xcodebuild or a hardcoded "macosx" value. This prevents
package managers and cross-compilation setups from providing their own
SDK path.

Guard the CMAKE_OSX_SYSROOT assignments with if(NOT CMAKE_OSX_SYSROOT)
so auto-detection only runs as a fallback. XCODE_ATTRIBUTE_SDKROOT
remains unconditional as it is a harmless Xcode project attribute.
@taylorhoward92 taylorhoward92 changed the title CMake: respect externally-set CMAKE_OSX_SYSROOT on macOS CMake: respect externally-set CMAKE_OSX_SYSROOT on macOS (v2-3) Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant