CMake: Set iOS default code style signing to Automatic

As far as I can see, the default is already 'Automatic' when it is
not specified, but it does improve some xcodebuild error messages in
certain edge cases if the option is specified explicitly.

Note that setting the style to Automatic will not suffice in order
to build the project from the command line with xcodebuild, if there
is no existing provisioning profile for the project in
~/Library/MobileDevice/Provisioning Profiles

You either need to build it once via the Xcode GUI, or you need to
call
  xcodebuild -allowProvisioningUpdates
which will try to create / download a provisioning profile from
Apple's server.

This implies that Xcode must have been launched at least once,
and configured with a valid Apple developer account, including
a free account.

qmake already generates a Makefile that calls
 xcodebuild -allowProvisioningUpdates.

CMake doesn't have a Makefile wrapper, so calling cmake --build .
will call xcodebuild directly, which again means users need to pass
-allowProvisioningUpdates explicitly.
It does not look like CMake intends to call it automatically
any time soon, see
https://gitlab.kitware.com/cmake/cmake/-/issues/22615

We intend to teach Qt Creator to add the -allowProvisioningUpdate
option when building a project using CMake.

The code sign style will not be set if the target
XCODE_ATTRIBUTE_CODE_SIGN_STYLE property or the
CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE variable has a value.

There's also an opt-out variable called
QT_NO_SET_XCODE_CODE_SIGN_STYLE

Pick-to: 6.2 6.3
Fixes: QTBUG-96347
Change-Id: If65ccb8a0393ff6d80e6caea3b8003fc59a8a62a
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-04 15:42:06 +02:00
parent 8370427c43
commit 9174321000

View File

@ -958,11 +958,27 @@ function(_qt_internal_set_xcode_targeted_device_family target)
endif()
endfunction()
function(_qt_internal_set_xcode_code_sign_style target)
if(NOT CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE
AND NOT QT_NO_SET_XCODE_CODE_SIGN_STYLE)
get_target_property(existing_code_style
"${target}" XCODE_ATTRIBUTE_CODE_SIGN_STYLE)
if(NOT existing_code_style)
set(existing_code_style "Automatic")
set_target_properties("${target}"
PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGN_STYLE
"${existing_code_style}")
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_set_xcode_code_sign_style("${target}")
_qt_internal_handle_ios_launch_screen("${target}")
_qt_internal_set_placeholder_apple_bundle_version("${target}")