Skip to content

Commit 1f3127a

Browse files
committed
Fix macos broken build due to cmake 4.0 upgrade
Cmake version 4 changes the behaviour of the CMAKE_OSX_SYSROOT variable so that it doesn't always get set. The build scripts use that variable to determine which version of the SDK is installed, and will fail if the variable is unset. The scripts need a different method to read the SDK version. 'xcrun' is a more reliable way of getting the SDK version. The --show-sdk-version flag returns the version number itself, and --show-sdk-path gives a path that was previously in the CMAKE_OSX_SYSROOT variable. Change the build scripts to use xcrun to obtain the path. Signed-off-by: Grant Likely <[email protected]>
1 parent 602c338 commit 1f3127a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.github/scripts/build-macos

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ TRAPZERR() {
3636
exit 2
3737
}
3838

39+
# Hack to work around cmake4 behaviour change on CMAKE_OSX_SYSROOT
40+
export SYSROOT=$(xcrun --sdk macosx --show-sdk-path)
41+
3942
build() {
4043
if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h}
4144
local host_os='macos'

cmake/macos/compilerconfig.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:-fopenmp-simd>")
1717
# Ensure recent enough Xcode and platform SDK
1818
set(_obs_macos_minimum_sdk 15.0) # Keep in sync with Xcode
1919
set(_obs_macos_minimum_xcode 16.0) # Keep in sync with SDK
20-
message(DEBUG "macOS SDK Path: ${CMAKE_OSX_SYSROOT}")
21-
string(REGEX MATCH ".+/MacOSX.platform/Developer/SDKs/MacOSX([0-9]+\\.[0-9])+\\.sdk$" _ ${CMAKE_OSX_SYSROOT})
22-
set(_obs_macos_current_sdk ${CMAKE_MATCH_1})
20+
execute_process(
21+
COMMAND xcrun --sdk macosx --show-sdk-version
22+
OUTPUT_VARIABLE _obs_macos_current_sdk
23+
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
24+
OUTPUT_STRIP_TRAILING_WHITESPACE)
2325
message(DEBUG "macOS SDK version: ${_obs_macos_current_sdk}")
2426
if(_obs_macos_current_sdk VERSION_LESS _obs_macos_minimum_sdk)
2527
message(

0 commit comments

Comments
 (0)