浏览代码

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.

(cherry picked from commit 8dd20dfd335dd07d2f1678c9cdf67894e09beab4)
gxalpha 2 年之前
父节点
当前提交
52b9552dfd
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      cmake/macos/compilerconfig.cmake

+ 14 - 0
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")