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 6.8
Change-Id: Ib62cf24ecc69a17ce1b52cd1f001aeff866051cd
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2024-11-12 14:03:05 +01:00
parent 2f35f69985
commit 76fef03f19

View File

@ -624,9 +624,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}"
@ -636,7 +633,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}
@ -645,9 +642,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}"
@ -657,7 +651,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}