Use add_dependencies to add the Android custom target dependencies

According to the CMake documentation we should use the add_dependencies
command to add dependencies on other targets for targets created
using the add_custom_target call.
Adjust the code for the Android targets.

Task-number: QTBUG-131653
Pick-to: 6.5 6.8
Change-Id: Iec9a3036f34f065f067568ecfca838345d35ff93
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2024-11-28 15:28:50 +01:00
parent 3378987e63
commit 312717d821

View File

@ -564,11 +564,11 @@ function(qt6_android_add_apk_target target)
"${apk_final_dir}/${target_file_copy_relative_path}"
)
add_custom_target(${target}_prepare_apk_dir ALL
DEPENDS ${target} ${extra_deps}
COMMAND ${copy_command}
COMMENT "Copying ${target} binary to apk folder"
${uses_terminal}
)
add_dependencies(${target}_prepare_apk_dir ${target} ${extra_deps})
set(sign_apk "")
if(QT_ANDROID_SIGN_APK)
@ -664,7 +664,6 @@ function(qt6_android_add_apk_target target)
add_custom_target(${target}_make_aar DEPENDS "${aar_final_file_path}")
else()
add_custom_target(${target}_make_apk
DEPENDS ${target}_prepare_apk_dir
COMMAND ${deployment_tool}
--input ${deployment_file}
--output ${apk_final_dir}
@ -677,7 +676,6 @@ function(qt6_android_add_apk_target target)
)
add_custom_target(${target}_make_aar
DEPENDS ${target}_prepare_apk_dir
COMMAND ${deployment_tool}
--input ${deployment_file}
--output ${apk_final_dir}
@ -688,13 +686,15 @@ function(qt6_android_add_apk_target target)
VERBATIM
${uses_terminal}
)
add_dependencies(${target}_make_apk ${target}_prepare_apk_dir)
add_dependencies(${target}_make_aar ${target}_prepare_apk_dir)
endif()
# Add target triggering AAB creation. Since the _make_aab target is not added to the ALL
# set, we may avoid dependency check for it and admit that the target is "always out
# of date".
add_custom_target(${target}_make_aab
DEPENDS ${target}_prepare_apk_dir
COMMAND ${deployment_tool}
--input ${deployment_file}
--output ${apk_final_dir}
@ -705,6 +705,7 @@ function(qt6_android_add_apk_target target)
COMMENT "Creating AAB for ${target}"
${uses_terminal}
)
add_dependencies(${target}_make_aab ${target}_prepare_apk_dir)
if(QT_IS_ANDROID_MULTI_ABI_EXTERNAL_PROJECT)
# When building per-ABI external projects we only need to copy ABI-specific libraries and