Skip to content

Commit d3db79a

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 d3db79a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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)