Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added platform option MAC_CATALYST_UNIVERSAL #210

Merged
merged 5 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/catalyst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ jobs:
DEPLOYMENT_TARGET: 17.2
steps:
- uses: actions/checkout@v2
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Build
run: ./.github/build.sh
build_with_15_4_MAC_CATALYST_UNIVERSAL:
name: "Xcode version 15.4, Target macOS Catalyst on Intel CPUs [x86_64] and Apple Silicon [arm64] Target SDK 17.2"
runs-on: macos-14
env:
PLATFORM: MAC_CATALYST_UNIVERSAL
DEPLOYMENT_TARGET: 17.2
steps:
- uses: actions/checkout@v2
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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 -- **Apple Silicon Required**
* _MAC_CATALYST_ - to build iOS for Mac (Catalyst, x86_64)
* _MAC_CATALYST_ARM64_ - to build iOS for Mac on Apple Silicon (Catalyst, arm64) -- **Apple Silicon Required**
* _MAC_CATALYST_UNIVERSAL_ - to build iOS for Mac on x86_64 and Mac on arm64 combined -- **Apple Silicon Required**

# 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")