From 5398eb55ed2125be2b2abeaa0ebafd5cac68e46d Mon Sep 17 00:00:00 2001 From: Bartlomiej Moskal Date: Thu, 19 May 2022 08:07:56 +0200 Subject: [PATCH] Android: Extend make_apk target with the sign option Commit contains the new QT_ANDROID_SIGN_APK variable. It extends *make_apk target by signing the package with the specified key. For key setup these environment variables must be set: - QT_ANDROID_KEYSTORE_PATH - QT_ANDROID_KEYSTORE_STORE_PASS - QT_ANDROID_KEYSTORE_ALIAS - QT_ANDROID_KEYSTORE_KEY_PASS Task-number: QTBUG-97107 Change-Id: If42c74298c1b385889b32517ab7f1f5b0628b487 Reviewed-by: Alexandru Croitor Reviewed-by: Alexey Edelev Reviewed-by: Assam Boudjelthia --- src/corelib/Qt6AndroidMacros.cmake | 6 +++++ .../src/cmake/cmake-configure-variables.qdoc | 27 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index cf996ebb4c5..91daa7b4c99 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -388,6 +388,10 @@ function(qt6_android_add_apk_target target) COMMENT "Copying ${target} binary to apk folder" ) + if(QT_ANDROID_SIGN_APK) + set(sign_apk "--sign") + endif() + set(extra_args "") if(QT_INTERNAL_NO_ANDROID_RCC_BUNDLE_CLEANUP) list(APPEND extra_args "--no-rcc-bundle-cleanup") @@ -422,6 +426,7 @@ function(qt6_android_add_apk_target target) --apk "${apk_final_file_path}" --depfile "${dep_file_path}" --builddir "${relative_to_dir}" + ${sign_apk} ${extra_args} COMMENT "Creating APK for ${target}" DEPENDS "${target}" "${deployment_file}" ${extra_deps} @@ -439,6 +444,7 @@ function(qt6_android_add_apk_target target) --input ${deployment_file} --output ${apk_final_dir} --apk ${apk_final_file_path} + ${sign_apk} ${extra_args} COMMENT "Creating APK for ${target}" ) diff --git a/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc b/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc index 25d69c36c30..116e08fef48 100644 --- a/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc +++ b/src/corelib/doc/src/cmake/cmake-configure-variables.qdoc @@ -1,4 +1,4 @@ -// Copyright (C) 2021 The Qt Company Ltd. +// Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /* NOTE: The variables documented here are available when running CMake, they @@ -155,6 +155,31 @@ Each variable can be used to specify the path to Qt for Android for the correspo \sa{cmake-variable-QT_ANDROID_ABIS}{QT_ANDROID_ABIS} */ +/*! +\page cmake-variable-QT_ANDROID_SIGN_APK.html +\ingroup cmake-variables-qtcore + +\title QT_ANDROID_SIGN_APK +\target cmake-variable-QT_ANDROID_SIGN_APK + +\summary {Sign the package with the specified keystore, alias and store password.} +\cmakevariablesince 6.4 +\preliminarycmakevariable +\cmakevariableandroidonly + +Sign the resulting package. The path of the keystore file, the alias of the key and passwords +have to be specified by additional environment variables: +\badcode + QT_ANDROID_KEYSTORE_PATH + QT_ANDROID_KEYSTORE_ALIAS + QT_ANDROID_KEYSTORE_STORE_PASS + QT_ANDROID_KEYSTORE_KEY_PASS +\endcode +Mentioned variables are used internally by \l{androiddeployqt}. + +\sa{androiddeployqt} +*/ + /*! \page cmake-variable-QT_HOST_PATH.html \ingroup cmake-variables-qtcore