Skip to content

SetOSX_SDK.cmake overrides requested CMAKE_OSX_SYSROOT #22378

@cho-m

Description

@cho-m

Check duplicate issues.

  • Checked for duplicates

Description

Seen while building 6.40.00 in Homebrew

At Homebrew, we pass in a specific -DCMAKE_OSX_SYSROOT=... to select the correct SDK we need to build for our distribution. This avoiding using incorrect CLT SDKs and/or Xcode SDKs that are installed on runner and aligns with all other packages we ship.

It looks like the new SetOSX_SDK.cmake does not respect this, even though comment claims it does:

# To choose an SDK, one has the following options:
# - Let xcrun choose the latest installed SDK: "cmake ..."
# - Configure an SDK using "SDKROOT=<path> cmake ..."
# - Set a cache variable: "cmake -DCMAKE_OSX_SYSROOT=<path> ..."

Main issue is the usage of ${...} to check if defined rather than the variable itself. Pretty much an if(TRUE) right now:

if(NOT DEFINED "${CMAKE_OSX_SYSROOT}")

Reproducer

  1. Unpack https://root.cern/download/root_v6.40.00.source.tar.gz
  2. cmake -Bbuild -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk (or other installed SDK, ignoring other options as visible without them)
  3. See output. In my case, I also have Xcode.app installed. In Homebrew CI, the wrong CLT SDK gets picked which causes build to fail.
    -- Mac OS SDK version: '26.5' /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.5.sdk
    

ROOT version

6.40.00

Installation method

Building from source (for Homebrew distribution)

Operating system

macOS

Additional context

When wrong SDK is picked, the build fails on handling <filesystem> detection - https://github.com/Homebrew/homebrew-core/actions/runs/26187130966/job/77067037892#step:3:155

  CMake Error at cmake/modules/SearchInstalledSoftware.cmake:1775 (message):
    Could not determine how to use C++17 <filesystem>
  Call Stack (most recent call first):
    CMakeLists.txt:134 (include)

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions