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
56 changes: 41 additions & 15 deletions cmake/macos/compilerconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,48 @@ include(compiler_common)
add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:-fopenmp-simd>")

# Ensure recent enough Xcode and platform SDK
set(_obs_macos_minimum_sdk 15.0) # Keep in sync with Xcode
set(_obs_macos_minimum_xcode 16.0) # Keep in sync with SDK
message(DEBUG "macOS SDK Path: ${CMAKE_OSX_SYSROOT}")
string(REGEX MATCH ".+/MacOSX.platform/Developer/SDKs/MacOSX([0-9]+\\.[0-9])+\\.sdk$" _ ${CMAKE_OSX_SYSROOT})
set(_obs_macos_current_sdk ${CMAKE_MATCH_1})
message(DEBUG "macOS SDK version: ${_obs_macos_current_sdk}")
if(_obs_macos_current_sdk VERSION_LESS _obs_macos_minimum_sdk)
message(
FATAL_ERROR
"Your macOS SDK version (${_obs_macos_current_sdk}) is too low. "
"The macOS ${_obs_macos_minimum_sdk} SDK (Xcode ${_obs_macos_minimum_xcode}) is required to build OBS."
function(check_sdk_requirements)
set(obs_macos_minimum_sdk 15.0) # Keep in sync with Xcode
set(obs_macos_minimum_xcode 16.0) # Keep in sync with SDK
execute_process(
COMMAND xcrun --sdk macosx --show-sdk-platform-version
OUTPUT_VARIABLE obs_macos_current_sdk
RESULT_VARIABLE result
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
unset(_obs_macos_current_sdk)
unset(_obs_macos_minimum_sdk)
unset(_obs_macos_minimum_xcode)
if(NOT result EQUAL 0)
message(
FATAL_ERROR
"Failed to fetch macOS SDK version. "
"Ensure that the macOS SDK is installed and that xcode-select points at the Xcode developer directory."
)
endif()
message(DEBUG "macOS SDK version: ${obs_macos_current_sdk}")
if(obs_macos_current_sdk VERSION_LESS obs_macos_minimum_sdk)
message(
FATAL_ERROR
"Your macOS SDK version (${obs_macos_current_sdk}) is too low. "
"The macOS ${obs_macos_minimum_sdk} SDK (Xcode ${obs_macos_minimum_xcode}) is required to build OBS."
)
endif()
execute_process(COMMAND xcrun --find xcodebuild OUTPUT_VARIABLE obs_macos_xcodebuild RESULT_VARIABLE result)
if(NOT result EQUAL 0)
message(
FATAL_ERROR
"Xcode was not found. "
"Ensure you have installed Xcode and that xcode-select points at the Xcode developer directory."
)
endif()
message(DEBUG "Path to xcodebuild binary: ${obs_macos_xcodebuild}")
if(XCODE_VERSION VERSION_LESS obs_macos_minimum_xcode)
message(
FATAL_ERROR
"Your Xcode version (${XCODE_VERSION}) is too low. Xcode ${obs_macos_minimum_xcode} is required to build OBS."
)
endif()
endfunction()

check_sdk_requirements()

# Enable dSYM generator for release builds
string(APPEND CMAKE_C_FLAGS_RELEASE " -g")
Expand Down
Loading