Skip to content

Commit

Permalink
Added platform option MAC_UNIVERSAL
Browse files Browse the repository at this point in the history
  • Loading branch information
DctrNoob committed Oct 24, 2022
1 parent c55677a commit 58d2b1d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Tested with the following combinations:
* _SIMULATOR_WATCHOS_ - to build for watchOS Simulator (i386)
* _MAC_ - to build for macOS (x86_64)
* _MAC_ARM64_ - to build for macOS on Apple Silicon (arm64)
* _MAC_UNIVERSAL_ - to build for macOS on x86_64 and Apple Silicon (arm64) combined
* _MAC_CATALYST_ - to build iOS for Mac (Catalyst, x86_64)
* _MAC_CATALYST_ARM64_ - to build iOS for Mac on Apple Silicon (Catalyst, arm64)

Expand Down
18 changes: 15 additions & 3 deletions ios.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator.
# MAC = Build for x86_64 macOS.
# MAC_ARM64 = Build for Apple Silicon macOS.
# MAC_UNIVERSAL = Combined build for x86_64 and Apple Silicon on macOS.
# MAC_CATALYST = Build for x86_64 macOS with Catalyst support (iOS toolchain on macOS).
# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS
# MAC_CATALYST_ARM64 = Build for Apple Silicon macOS with Catalyst support (iOS toolchain on macOS).
Expand Down Expand Up @@ -111,6 +112,7 @@
# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated)
# MAC = x86_64
# MAC_ARM64 = arm64
# MAC_UNIVERSAL = x86_64 arm64
# MAC_CATALYST = x86_64
# MAC_CATALYST_ARM64 = arm64
#
Expand Down Expand Up @@ -154,7 +156,7 @@ list(APPEND _supported_platforms
"OS" "OS64" "OS64COMBINED" "SIMULATOR" "SIMULATOR64" "SIMULATORARM64"
"TVOS" "TVOSCOMBINED" "SIMULATOR_TVOS"
"WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS"
"MAC" "MAC_ARM64"
"MAC" "MAC_ARM64" "MAC_UNIVERSAL"
"MAC_CATALYST" "MAC_CATALYST_ARM64")

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

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

Expand Down Expand Up @@ -258,6 +260,9 @@ if(NOT DEFINED DEPLOYMENT_TARGET)
elseif(PLATFORM STREQUAL "MAC_ARM64")
# Unless specified, SDK version 11.0 (Big Sur) is used by default as minimum target version (macos on arm).
set(DEPLOYMENT_TARGET "11.0")
elseif(PLATFORM STREQUAL "MAC_UNIVERSAL")
# Unless specified, SDK version 11.0 (Big Sur) is used by default as minimum target version for universal builds.
set(DEPLOYMENT_TARGET "11.0")
elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64")
# Unless specified, SDK version 13.0 is used by default as minimum target version (mac catalyst minimum requirement).
set(DEPLOYMENT_TARGET "13.1")
Expand Down Expand Up @@ -459,6 +464,13 @@ elseif(PLATFORM_INT MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$")
elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_ARM64")
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi)
endif()
elseif(PLATFORM_INT STREQUAL "MAC_UNIVERSAL")
set(SDK_NAME macosx)
if(NOT ARCHS)
set(ARCHS "x86_64;arm64")
endif()
string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}")
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET})
else()
message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}")
endif()
Expand Down Expand Up @@ -658,7 +670,7 @@ endif()
set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "")
set(UNIX ON CACHE BOOL "")
set(APPLE ON CACHE BOOL "")
if(PLATFORM STREQUAL "MAC" OR PLATFORM STREQUAL "MAC_ARM64")
if(PLATFORM STREQUAL "MAC" OR PLATFORM STREQUAL "MAC_ARM64" OR PLATFORM STREQUAL "MAC_UNIVERSAL")
set(IOS OFF CACHE BOOL "")
set(MACOS ON CACHE BOOL "")
elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64")
Expand Down

0 comments on commit 58d2b1d

Please sign in to comment.