浏览代码

cmake: Remove enforced architectures for macOS builds

Ideally CMAKE_OSX_ARCHITECTURES should not be set automatically within
the project but should exclusively be a cache or environment variable
provided by the developer.

This would also match the requirement mentioned by the CMake
documentation that the value should be set before the first project()
call.

If this variable is not set, the Xcode generator would default to the
native platform of the host, but the buildspec system as well as the
"add_obs_plugin" function need a local "architecture" to work, so
use "CMAKE_HOST_SYSTEM_PROCESSOR" instead if CMAKE_OSX_ARCHITECTURES
was not provided.
PatTheMav 2 月之前
父节点
当前提交
4c912358a9
共有 3 个文件被更改,包括 8 次插入8 次删除
  1. 4 1
      cmake/common/buildspec_common.cmake
  2. 4 1
      cmake/common/helpers_common.cmake
  3. 0 6
      cmake/macos/compilerconfig.cmake

+ 4 - 1
cmake/common/buildspec_common.cmake

@@ -59,8 +59,11 @@ function(_check_dependencies)
     if(dependency STREQUAL cef AND arch STREQUAL universal)
       if(CMAKE_OSX_ARCHITECTURES MATCHES ".+;.+")
         continue()
+      elseif(CMAKE_OSX_ARCHITECTURES MATCHES "(arm64|x86_64)")
+        set(arch ${CMAKE_OSX_ARCHITECTURES})
+      else()
+        set(arch ${CMAKE_HOST_SYSTEM_PROCESSOR})
       endif()
-      set(arch ${CMAKE_OSX_ARCHITECTURES})
       set(platform macos-${arch})
     endif()
 

+ 4 - 1
cmake/common/helpers_common.cmake

@@ -477,7 +477,10 @@ function(add_obs_plugin target)
           set(found_architecture TRUE)
         endif()
       elseif(OS_MACOS)
-        if("${architecture}" IN_LIST CMAKE_OSX_ARCHITECTURES)
+        if(
+          "${architecture}" IN_LIST CMAKE_OSX_ARCHITECTURES
+          OR "${architecture}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}"
+        )
           set(found_architecture TRUE)
         endif()
       elseif("${architecture}" STREQUAL CMAKE_SYSTEM_PROCESSOR)

+ 0 - 6
cmake/macos/compilerconfig.cmake

@@ -14,12 +14,6 @@ include(compiler_common)
 
 add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:-fopenmp-simd>")
 
-# Enable selection between arm64 and x86_64 targets
-if(NOT CMAKE_OSX_ARCHITECTURES)
-  set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "Build architectures for macOS" FORCE)
-endif()
-set_property(CACHE CMAKE_OSX_ARCHITECTURES PROPERTY STRINGS arm64 x86_64)
-
 # Ensure recent enough Xcode and platform SDK
 function(check_sdk_requirements)
   set(obs_macos_minimum_sdk 15.0) # Keep in sync with Xcode