Android: add opt-out for release package signing

Release and RelWithDebInfo builds always default to passing
--release to androiddeployqt. There is an opt-in variable
(QT_ANDROID_DEPLOY_RELEASE), presumably for Debug builds,
but there is no opt-out for non-Debug builds. Instead,
there is a hack for autotests.

In addition to tests, there are situations during development
where we want to deploy a release build, but do not have or
want to set up the release signing infrastructure. Having a
variable to opt-out is then very useful.

Change-Id: I6c6b9aaccad7d9d4f86745f3ed7d3c475b383ad3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Laszlo Agocs 2023-11-06 10:29:58 +01:00
parent 740d3a6b51
commit abdef932b8
2 changed files with 39 additions and 5 deletions

View File

@ -432,8 +432,17 @@ function(qt6_android_add_apk_target target)
if(QT_ENABLE_VERBOSE_DEPLOYMENT)
list(APPEND extra_args "--verbose")
endif()
if(QT_ANDROID_DEPLOY_RELEASE)
if(QT_ANDROID_DEPLOY_RELEASE) # legacy opt-in variable
set(QT_ANDROID_DEPLOYMENT_TYPE "RELEASE")
endif()
# Setting QT_ANDROID_DEPLOYMENT_TYPE to a value other than Release disables
# release package signing regardless of the build type.
if(QT_ANDROID_DEPLOYMENT_TYPE)
string(TOUPPER "${QT_ANDROID_DEPLOYMENT_TYPE}" deployment_type_upper)
if("${deployment_type_upper}" STREQUAL "RELEASE")
list(APPEND extra_args "--release")
endif()
elseif(NOT QT_BUILD_TESTS)
# Workaround for tests: do not set automatically --release flag if QT_BUILD_TESTS is set.
# Release package need to be signed. Signing is currently not supported by CI.

View File

@ -86,14 +86,39 @@ is written out as part of the deployment settings for a target.
\title QT_ANDROID_DEPLOY_RELEASE
\target cmake-variable-QT_ANDROID_DEPLOY_RELEASE
\summary {Sets the package type as a release.}
\summary {Forces release package signing regardless of the build type.}
\cmakevariablesince 6.5.2
\preliminarycmakevariable
\cmakevariableandroidonly
When set to \c TRUE, allows you to create a release package
by passing the \c --release flag to the \c androiddeployqt tool.
When set to \c TRUE, the \c --release flag is passed to the \c androiddeployqt
tool, even when the application build mode is Debug. In Release and
RelWithDebInfo builds this is the default. For more control over this, prefer
using \l QT_ANDROID_DEPLOYMENT_TYPE instead.
\sa {androiddeployqt}
*/
/*!
\page cmake-variable-qt-android-deployment-type.html
\ingroup cmake-variables-qtcore
\title QT_ANDROID_DEPLOYMENT_TYPE
\target cmake-variable-QT_ANDROID_DEPLOYMENT_TYPE
\summary {Forces or disables release package signing regardless of the build type.}
\cmakevariablesince 6.7
\preliminarycmakevariable
\cmakevariableandroidonly
When set to \c Release, the \c --release flag is passed to the \c
androiddeployqt tool, regardless of the application build type. When set to
another value, the \c --release flag is never passed to the tool, which
effectively disables release package signing even in Release or RelWithDebInfo
builds. When not set, the default behavior is to use release package signing in
build types other than Debug.
\sa {androiddeployqt}
*/