CMake: Set default xcode device family to iPhone and iPad

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 <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2022-05-03 18:17:37 +02:00
parent e2620b538b
commit 8370427c43

View File

@ -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}")