From 8370427c43ee1a9e52cadd24fd67a7a18ef08230 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 3 May 2022 18:17:37 +0200 Subject: [PATCH] CMake: Set default xcode device family to iPhone and iPad MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This matches what we do with qmake, which means a build application can be deployed to either an iPhone or an iPad by default, without having to fiddle with Xcode settings. The device family will not be set if the target XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY property or the CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY variable has a value. There's also an opt-out variable called QT_NO_SET_XCODE_TARGETED_DEVICE_FAMILY Pick-to: 6.2 6.3 Fixes: QTBUG-100833 Change-Id: I8cde10975b44af81cfa18f985523c8ec1529386d Reviewed-by: Alexey Edelev Reviewed-by: Jörg Bornemann --- src/corelib/Qt6CoreMacros.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 3e040ff2bde..0e11592e28c 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -943,10 +943,26 @@ function(_qt_internal_set_xcode_product_bundle_identifier target) endif() endfunction() +function(_qt_internal_set_xcode_targeted_device_family target) + if(NOT CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY + AND NOT QT_NO_SET_XCODE_TARGETED_DEVICE_FAMILY) + get_target_property(existing_device_family + "${target}" XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY) + if(NOT existing_device_family) + set(device_family_iphone_and_ipad "1,2") + set_target_properties("${target}" + PROPERTIES + XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY + "${device_family_iphone_and_ipad}") + endif() + endif() +endfunction() + function(_qt_internal_finalize_ios_app target) _qt_internal_set_xcode_development_team_id("${target}") _qt_internal_set_xcode_bundle_identifier("${target}") _qt_internal_set_xcode_product_bundle_identifier("${target}") + _qt_internal_set_xcode_targeted_device_family("${target}") _qt_internal_handle_ios_launch_screen("${target}") _qt_internal_set_placeholder_apple_bundle_version("${target}")