Skip to content

Commit 4c91235

Browse files
PatTheMavRytoEX
authored andcommitted
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.
1 parent 363874b commit 4c91235

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

cmake/common/buildspec_common.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ function(_check_dependencies)
5959
if(dependency STREQUAL cef AND arch STREQUAL universal)
6060
if(CMAKE_OSX_ARCHITECTURES MATCHES ".+;.+")
6161
continue()
62+
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "(arm64|x86_64)")
63+
set(arch ${CMAKE_OSX_ARCHITECTURES})
64+
else()
65+
set(arch ${CMAKE_HOST_SYSTEM_PROCESSOR})
6266
endif()
63-
set(arch ${CMAKE_OSX_ARCHITECTURES})
6467
set(platform macos-${arch})
6568
endif()
6669

cmake/common/helpers_common.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,10 @@ function(add_obs_plugin target)
477477
set(found_architecture TRUE)
478478
endif()
479479
elseif(OS_MACOS)
480-
if("${architecture}" IN_LIST CMAKE_OSX_ARCHITECTURES)
480+
if(
481+
"${architecture}" IN_LIST CMAKE_OSX_ARCHITECTURES
482+
OR "${architecture}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}"
483+
)
481484
set(found_architecture TRUE)
482485
endif()
483486
elseif("${architecture}" STREQUAL CMAKE_SYSTEM_PROCESSOR)

cmake/macos/compilerconfig.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ include(compiler_common)
1414

1515
add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:-fopenmp-simd>")
1616

17-
# Enable selection between arm64 and x86_64 targets
18-
if(NOT CMAKE_OSX_ARCHITECTURES)
19-
set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "Build architectures for macOS" FORCE)
20-
endif()
21-
set_property(CACHE CMAKE_OSX_ARCHITECTURES PROPERTY STRINGS arm64 x86_64)
22-
2317
# Ensure recent enough Xcode and platform SDK
2418
function(check_sdk_requirements)
2519
set(obs_macos_minimum_sdk 15.0) # Keep in sync with Xcode

0 commit comments

Comments
 (0)