-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
CMakeLists: Support building for iOS #12672
Conversation
CMakeLists.txt
Outdated
if(VCPKG_TARGET_TRIPLET MATCHES "^[a-zA-Z0-9]+-osx") | ||
message(STATUS "Targeting macOS (${VCPKG_TARGET_TRIPLET})") | ||
set(CMAKE_SYSTEM_NAME Darwin CACHE STRING "Target macOS") | ||
if(VCPKG_TARGET_TRIPLET MATCHES "^arm64-") | ||
# Minimum macOS version for arm64 Support | ||
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0 CACHE STRING "Minimum macOS version the build will be able to run on") | ||
set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "The target achritecture") | ||
set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "The target architecture") | ||
set(CMAKE_SYSTEM_PROCESSOR arm64 CACHE STRING "The target system processor") | ||
set(CMAKE_SYSTEM_NAME Darwin CACHE STRING "Setting this enables CMAKE_CROSSCOMPILE") | ||
else() | ||
# Minimum macOS version supported by Qt 5.12 | ||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum macOS version the build will be able to run on") | ||
if(NOT VCPKG_TARGET_TRIPLET) | ||
set(VCPKG_TARGET_TRIPLET "x64-osx-min1012") | ||
if(QT6) | ||
# Minimum macOS version supported by Qt 6 | ||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15 CACHE STRING "Minimum macOS version the build will be able to run on") | ||
else() | ||
# Minimum macOS version supported by Qt 5.12 | ||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum macOS version the build will be able to run on") | ||
# Needed for deployment target < 10.14 | ||
add_compile_options(-fno-aligned-allocation) | ||
endif() | ||
# Needed for deployment target < 10.14 | ||
add_compile_options(-fno-aligned-allocation) | ||
endif() | ||
elseif(VCPKG_TARGET_TRIPLET MATCHES "^[a-zA-Z0-9]+-ios") | ||
message(STATUS "Targeting iOS (${VCPKG_TARGET_TRIPLET})") | ||
set(CMAKE_SYSTEM_NAME iOS CACHE STRING "Target iOS") | ||
set(CMAKE_OSX_DEPLOYMENT_TARGET 14.0 CACHE STRING "Minimum iOS version to target") | ||
else() | ||
message(WARNING "Targeting an Apple platform, but VCPKG_TARGET_TRIPLET is not set. This is not a supported scenario!") | ||
endif() | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation note: This logic slightly refactors the macOS part too and is based on the current main
. I believe the clear separation between macOS (arm64/x64) and iOS is worth it.
On the next 2.4 -> main
merge this will produce a conflict, in which case this entire incoming hunk should be picked, as it already includes the main
's changes (mostly just making the arm64
regex more general).
Is 2.4 really the correct target for this PR? It should be for bugfixes only. |
Since the majority of this logic doesn't apply to the desktop 2.4 builds anyway, I think not having to deal with merge conflicts would be worth it here (even minor things such as adding a source file could get annoying when 2.5 wraps everything into a But I'd be open to target 2.5/main too if making changes to the build logic right before a stable release is too risky. In that case I would retarget #12676 too (since the PRs essentially depend on each other, but are split for easier reviewability). |
This change looks to risky for me at least in the current phase of 2.4.0 release candidate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix our plan before merge.
Seems reasonable, I'll rebase this one and #12676. Could you take a look at merging 2.4 to |
I can do it tonight, it is also welcome to do it yourself. Don't know if there are difficult conflicts. |
Marking as a draft for now, once #12685 is merged, I'll retarget this to |
dd0c438
to
fb7211d
Compare
endif() | ||
elseif(VCPKG_TARGET_TRIPLET MATCHES "^[a-zA-Z0-9]+-ios") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have now a redundant way to select IOS, can we ditch the external IOS flag and handle everything automatically using the VCPKG_TARGET_TRIPLET?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IOS
flag is set by CMake, so it's pretty much what we do: https://cmake.org/cmake/help/latest/variable/IOS.html#ios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, I was not aware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think at least a check of IOS is missing when dealing with the triplets.
This PR implements the necessary changes to instruct CMake to build for iOS. This mainly boils down to:
CMAKE_SYSTEM_NAME
to iOSNOT IOS
conditionThe rationale for targeting 2.4 is that, even if we don't build 2.4 for iOS, we avoid painful merge conflicts in the future by already having the relevant conditionals in place.