Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,32 @@ if(WIN32)
cmake_policy(SET CMP0091 OLD)
set(CMAKE_SKIP_TEST_ALL_DEPENDENCY TRUE)
endif()
if(CMAKE_HOST_APPLE AND (NOT CMAKE_OSX_SYSROOT OR CMAKE_OSX_SYSROOT STREQUAL ""))
# The SYSROOT *must* be set before the project() call
# TODO: The following code is *necessary* on a standard MacOS platform (e.g. an Apple MacOS machine), but may not
# be as necessary on other MacOS platforms (e.g. Nix). A PR removed the following code https://github.com/root-project/root/pull/19718
# and the CI was happy with it, but unfortunately it was working simply because during our CI run jobs something is
# setting the SDKROOT environment variable, which implicitly sets the CMAKE_OSX_SYSROOT variable. This was highlighted
# by another PR https://github.com/root-project/root/pull/19855. On a standard Apple MacOS system, where the SDKROOT
# variable is not set by default, the build of ROOT would fail without the following code. It is unclear what is setting
# the SDKROOT variable only during our CI jobs, logging to the same CI machines and launching a build manually shows
# the same build error.
find_program(XCRUN_EXECUTABLE xcrun)
if(EXISTS ${XCRUN_EXECUTABLE})
execute_process(COMMAND ${XCRUN_EXECUTABLE} --sdk macosx --show-sdk-path
OUTPUT_VARIABLE SDK_PATH
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT EXISTS "${SDK_PATH}")
message(FATAL_ERROR "Could not detect macOS SDK path")
endif()

set(CMAKE_OSX_SYSROOT "${SDK_PATH}" CACHE PATH "SDK path" FORCE)
else()
message(WARNING "The CMAKE_OSX_SYSROOT variable is not set and the 'xcrun' executable is not available. "
"This build of ROOT might not be able to find the correct MacOS SDK.")
endif()
endif()

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE)
message(FATAL_ERROR
Expand Down
Loading