Skip to content

Commit

Permalink
Added platform option MAC_CATALYST_UNIVERSAL
Browse files Browse the repository at this point in the history
Update README.md

fixed a typo

fixed help text
  • Loading branch information
oliverepper committed Jul 18, 2024
1 parent a52c591 commit d16c291
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ A CMake toolchain file for iOS (+ Catalyst), watchOS, tvOS and macOS development
* _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)
* _MAC_CATALYST_UNIVERSAL_ - to build iOS for Mac on x86_64 and Mac on arm64 combined

# Example usage

Expand Down
17 changes: 13 additions & 4 deletions ios.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
# 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).
# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS
# MAC_CATALYST_UNIVERSAL = Combined build for x86_64 and Apple Silicon on Catalyst.
#
# CMAKE_OSX_SYSROOT: Path to the SDK to use. By default this is
# automatically determined from PLATFORM and xcodebuild, but
Expand Down Expand Up @@ -123,6 +124,7 @@
# MAC_UNIVERSAL = x86_64 arm64
# MAC_CATALYST = x86_64
# MAC_CATALYST_ARM64 = arm64
# MAC_CATALYST_UNIVERSAL = x86_64 arm64
#
# NOTE: When manually specifying ARCHS, put a semi-colon between the entries. E.g., -DARCHS="armv7;arm64"
#
Expand Down Expand Up @@ -166,7 +168,7 @@ list(APPEND _supported_platforms
"WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" "SIMULATORARM64_WATCHOS"
"MAC" "MAC_ARM64" "MAC_UNIVERSAL"
"VISIONOS" "SIMULATOR_VISIONOS" "VISIONOSCOMBINED"
"MAC_CATALYST" "MAC_CATALYST_ARM64")
"MAC_CATALYST" "MAC_CATALYST_ARM64" "MAC_CATALYST_UNIVERSAL")

# Cache what generator is used
set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
Expand Down Expand Up @@ -230,7 +232,7 @@ if("${contains_PLATFORM}" EQUAL "-1")
endif()

# Check if Apple Silicon is supported
if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$|^(MAC_UNIVERSAL)$" AND ${CMAKE_VERSION} VERSION_LESS "3.19.5")
if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$|^(MAC_UNIVERSAL)$|^(MAC_CATALYST_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 @@ -275,7 +277,7 @@ if(NOT DEFINED DEPLOYMENT_TARGET)
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")
elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64" OR PLATFORM STREQUAL "MAC_CATALYST_UNIVERSAL")
# Unless specified, SDK version 13.0 is used by default as the minimum target version (mac catalyst minimum requirement).
set(DEPLOYMENT_TARGET "13.1")
else()
Expand Down Expand Up @@ -553,6 +555,13 @@ elseif(PLATFORM_INT STREQUAL "MAC_UNIVERSAL")
endif()
string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}")
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET})
elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_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-ios${DEPLOYMENT_TARGET}-macabi)
else()
message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}")
endif()
Expand Down Expand Up @@ -761,7 +770,7 @@ set(APPLE ON CACHE BOOL "")
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")
elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64" OR PLATFORM STREQUAL "MAC_CATALYST_UNIVERSAL")
set(IOS ON CACHE BOOL "")
set(MACOS ON CACHE BOOL "")
elseif(PLATFORM STREQUAL "VISIONOS" OR PLATFORM STREQUAL "SIMULATOR_VISIONOS" OR PLATFORM STREQUAL "VISIONOSCOMBINED")
Expand Down

0 comments on commit d16c291

Please sign in to comment.