From 8dd20dfd335dd07d2f1678c9cdf67894e09beab4 Mon Sep 17 00:00:00 2001 From: gxalpha Date: Thu, 12 Oct 2023 13:11:16 +0200 Subject: [PATCH] cmake: Explicitly fail if macOS SDK is too old Adds a check to explicitly make sure that the macOS SDK being used is recent enough to build OBS. OBS code currently has ifdefs for older SDKs in some but not all places and relies on some frameworks existing that do not exist on older versions, this should clarify what we require. This commit sets the minimum SDK to 13.1 as this is what our wiki currently specifies. This can be increased in the future if required. --- cmake/macos/compilerconfig.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmake/macos/compilerconfig.cmake b/cmake/macos/compilerconfig.cmake index 8c2e2f158..4cca6bfe4 100644 --- a/cmake/macos/compilerconfig.cmake +++ b/cmake/macos/compilerconfig.cmake @@ -15,6 +15,20 @@ if(NOT CMAKE_OSX_ARCHITECTURES) endif() set_property(CACHE CMAKE_OSX_ARCHITECTURES PROPERTY STRINGS arm64 x86_64) +# Make sure the macOS SDK is recent enough for OBS +set(OBS_MACOS_MINIMUM_SDK "13.1") # Keep in sync with Xcode +set(OBS_MACOS_MINIMUM_XCODE "14.2") # 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." + ) +endif() + if(XCODE) # Enable dSYM generator for release builds string(APPEND CMAKE_C_FLAGS_RELEASE " -g")