Skip to content

Commit 5a2cafa

Browse files
authored
Merge pull request #163 from DctrNoob/162_macos_universal
Added platform option MAC_UNIVERSAL (Issue 162)
2 parents 63c7192 + 58d2b1d commit 5a2cafa

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Tested with the following combinations:
4343
* _SIMULATOR_WATCHOS_ - to build for watchOS Simulator (i386)
4444
* _MAC_ - to build for macOS (x86_64)
4545
* _MAC_ARM64_ - to build for macOS on Apple Silicon (arm64)
46+
* _MAC_UNIVERSAL_ - to build for macOS on x86_64 and Apple Silicon (arm64) combined
4647
* _MAC_CATALYST_ - to build iOS for Mac (Catalyst, x86_64)
4748
* _MAC_CATALYST_ARM64_ - to build iOS for Mac on Apple Silicon (Catalyst, arm64)
4849

ios.toolchain.cmake

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator.
7171
# MAC = Build for x86_64 macOS.
7272
# MAC_ARM64 = Build for Apple Silicon macOS.
73+
# MAC_UNIVERSAL = Combined build for x86_64 and Apple Silicon on macOS.
7374
# MAC_CATALYST = Build for x86_64 macOS with Catalyst support (iOS toolchain on macOS).
7475
# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS
7576
# MAC_CATALYST_ARM64 = Build for Apple Silicon macOS with Catalyst support (iOS toolchain on macOS).
@@ -111,6 +112,7 @@
111112
# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated)
112113
# MAC = x86_64
113114
# MAC_ARM64 = arm64
115+
# MAC_UNIVERSAL = x86_64 arm64
114116
# MAC_CATALYST = x86_64
115117
# MAC_CATALYST_ARM64 = arm64
116118
#
@@ -154,7 +156,7 @@ list(APPEND _supported_platforms
154156
"OS" "OS64" "OS64COMBINED" "SIMULATOR" "SIMULATOR64" "SIMULATORARM64"
155157
"TVOS" "TVOSCOMBINED" "SIMULATOR_TVOS"
156158
"WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS"
157-
"MAC" "MAC_ARM64"
159+
"MAC" "MAC_ARM64" "MAC_UNIVERSAL"
158160
"MAC_CATALYST" "MAC_CATALYST_ARM64")
159161

160162
# Cache what generator is used
@@ -219,7 +221,7 @@ if("${contains_PLATFORM}" EQUAL "-1")
219221
endif()
220222

221223
# Check if Apple Silicon is supported
222-
if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$" AND ${CMAKE_VERSION} VERSION_LESS "3.19.5")
224+
if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$|^(MAC_UNIVERSAL)$" AND ${CMAKE_VERSION} VERSION_LESS "3.19.5")
223225
message(FATAL_ERROR "Apple Silicon builds requires a minimum of CMake 3.19.5")
224226
endif()
225227

@@ -258,6 +260,9 @@ if(NOT DEFINED DEPLOYMENT_TARGET)
258260
elseif(PLATFORM STREQUAL "MAC_ARM64")
259261
# Unless specified, SDK version 11.0 (Big Sur) is used by default as the minimum target version (macOS on arm).
260262
set(DEPLOYMENT_TARGET "11.0")
263+
elseif(PLATFORM STREQUAL "MAC_UNIVERSAL")
264+
# Unless specified, SDK version 11.0 (Big Sur) is used by default as minimum target version for universal builds.
265+
set(DEPLOYMENT_TARGET "11.0")
261266
elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64")
262267
# Unless specified, SDK version 13.0 is used by default as the minimum target version (mac catalyst minimum requirement).
263268
set(DEPLOYMENT_TARGET "13.1")
@@ -459,6 +464,13 @@ elseif(PLATFORM_INT MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$")
459464
elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_ARM64")
460465
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi)
461466
endif()
467+
elseif(PLATFORM_INT STREQUAL "MAC_UNIVERSAL")
468+
set(SDK_NAME macosx)
469+
if(NOT ARCHS)
470+
set(ARCHS "x86_64;arm64")
471+
endif()
472+
string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}")
473+
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET})
462474
else()
463475
message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}")
464476
endif()
@@ -658,7 +670,7 @@ endif()
658670
set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "")
659671
set(UNIX ON CACHE BOOL "")
660672
set(APPLE ON CACHE BOOL "")
661-
if(PLATFORM STREQUAL "MAC" OR PLATFORM STREQUAL "MAC_ARM64")
673+
if(PLATFORM STREQUAL "MAC" OR PLATFORM STREQUAL "MAC_ARM64" OR PLATFORM STREQUAL "MAC_UNIVERSAL")
662674
set(IOS OFF CACHE BOOL "")
663675
set(MACOS ON CACHE BOOL "")
664676
elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64")

0 commit comments

Comments
 (0)