Allow calling qt6_android_add_apk_target twice

If qt6_android_add_apk_target is called manually in user project this
might cause duplicated targets issue when calling the finalizer(either
manually or in a defer call).
Skip the qt6_android_add_apk_target body if target is already
registered in _qt_apk_targets list.

Pick-to: 6.3
Change-Id: I36ef569227e0c5f0f077446bbe5d7e8d8fc0bfc6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Alexey Edelev 2022-02-22 16:05:58 +01:00
parent bb209b5715
commit 708eb85e38

View File

@ -323,6 +323,12 @@ endif()
# Add custom target to package the APK
function(qt6_android_add_apk_target target)
# Avoid calling qt6_android_add_apk_target twice
get_property(apk_targets GLOBAL PROPERTY _qt_apk_targets)
if("${target}" IN_LIST apk_targets)
return()
endif()
get_target_property(deployment_file ${target} QT_ANDROID_DEPLOYMENT_SETTINGS_FILE)
if (NOT deployment_file)
message(FATAL_ERROR "Target ${target} is not a valid android executable target\n")