CMake: Override simulator architecture to x86_64 for Xcode generator

The simulator build of Qt for iOS is currently x86_64 only, instead
of universal builds with an arm64 slice as well, since we don't
support xcframeworks. This means we can't rely on Xcode's default
simulator arch settings, which on an Apple Silicon Mac will be
arm64.

Instead we override the simulator arch, like we do for qmake.

Pick-to: 6.4 6.3 6.2
Change-Id: I8b52389db1b83f4f9679c724bcde53b44dbc76f1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Tor Arne Vestbø 2022-08-03 16:51:34 +02:00
parent 3f450a6ba0
commit 6ec21881dd
2 changed files with 29 additions and 2 deletions

View File

@ -198,8 +198,8 @@ set(__qt_chainload_toolchain_file \"\${__qt_initially_configured_toolchain_file}
# xcodebuild from the command line would try to build with the wrong architecture. Also
# provide an opt-out option just in case.
#
# For a multi-architecture build (so simulator_and_device) we don't set an explicit
# architecture and let Xcode and the developer handle it.
# For a multi-architecture build (so simulator_and_device) we set an explicit
# architecture for simulator only, via _qt_internal_set_ios_simulator_arch.
#
# When using the Ninja generator, specify the first architecture from QT_OSX_ARCHITECTURES
# (even with a simulator_and_device Qt build). This ensures that the default configuration

View File

@ -1223,6 +1223,32 @@ function(_qt_internal_generate_ios_info_plist target)
set_target_properties("${target}" PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${info_plist_out}")
endfunction()
function(_qt_internal_set_ios_simulator_arch target)
if(CMAKE_XCODE_ATTRIBUTE_ARCHS
OR QT_NO_SET_XCODE_ARCHS)
return()
endif()
get_target_property(existing_archs
"${target}" XCODE_ATTRIBUTE_ARCHS)
if(NOT existing_archs MATCHES "-NOTFOUND")
return()
endif()
if(NOT x86_64 IN_LIST QT_OSX_ARCHITECTURES)
return()
endif()
if(CMAKE_OSX_ARCHITECTURES AND NOT x86_64 IN_LIST CMAKE_OSX_ARCHITECTURES)
return()
endif()
set_target_properties("${target}"
PROPERTIES
"XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*]"
"x86_64")
endfunction()
function(_qt_internal_finalize_apple_app target)
# Shared between macOS and iOS apps
_qt_internal_set_xcode_development_team_id("${target}")
@ -1240,6 +1266,7 @@ function(_qt_internal_finalize_ios_app target)
_qt_internal_set_xcode_bitcode_enablement("${target}")
_qt_internal_handle_ios_launch_screen("${target}")
_qt_internal_generate_ios_info_plist("${target}")
_qt_internal_set_ios_simulator_arch("${target}")
endfunction()
function(_qt_internal_finalize_macos_app target)