Android: Do not duplicate copy_if_different command for android target

The CMake copy_if_different command, which copies the android target
library to a libs/<arch> directory could be executed in different code
paths which caused a multiple access to a same file in a filesystem.

Avoid doing this and depend on <target>_prepare_apk_dir target for the
depfile code path too.

Pick-to: 6.5
Change-Id: Ib62cf24ecc69a17ce1b52cd1f001aeff866051cd
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 76fef03f19ab2a41ec9fdc9a72a08b5e1ea80a95)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexey Edelev 2024-11-12 14:03:05 +01:00 committed by Qt Cherry-pick Bot
parent b52a0f8e10
commit 97420aaa46

View File

@ -524,9 +524,6 @@ function(qt6_android_add_apk_target target)
# Add custom command that creates the apk and triggers rebuild if files listed in
# ${dep_file_path} are changed.
add_custom_command(OUTPUT "${apk_final_file_path}"
COMMAND ${CMAKE_COMMAND}
-E copy "$<TARGET_FILE:${target}>"
"${apk_final_dir}/${target_file_copy_relative_path}"
COMMAND "${deployment_tool}"
--input "${deployment_file}"
--output "${apk_final_dir}"
@ -536,7 +533,7 @@ function(qt6_android_add_apk_target target)
${extra_args}
${sign_apk}
COMMENT "Creating APK for ${target}"
DEPENDS "${target}" "${deployment_file}" ${extra_deps}
DEPENDS "${target}" "${deployment_file}" ${extra_deps} ${target}_prepare_apk_dir
DEPFILE "${dep_file_path}"
VERBATIM
${uses_terminal}
@ -545,9 +542,6 @@ function(qt6_android_add_apk_target target)
# Add custom command that creates the aar and triggers rebuild if files listed in
# ${dep_file_path} are changed.
add_custom_command(OUTPUT "${aar_final_file_path}"
COMMAND ${CMAKE_COMMAND}
-E copy "$<TARGET_FILE:${target}>"
"${apk_final_dir}/${target_file_copy_relative_path}"
COMMAND "${deployment_tool}"
--input "${deployment_file}"
--output "${apk_final_dir}"
@ -557,7 +551,7 @@ function(qt6_android_add_apk_target target)
--build-aar
${extra_args}
COMMENT "Creating AAR for ${target}"
DEPENDS "${target}" "${deployment_file}" ${extra_deps}
DEPENDS "${target}" "${deployment_file}" ${extra_deps} ${target}_prepare_apk_dir
DEPFILE "${dep_file_path}"
VERBATIM
${uses_terminal}