summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2021-11-17 20:00:08 +0100
committerAlexey Edelev <alexey.edelev@qt.io>2021-11-26 18:28:50 +0100
commit271ea6cd3ee8a3df281ce52e2160ad016ea2e86b (patch)
tree940f7d06695ec58b8506bd4cf04f8a150e3a41a9 /src
parentaba1432daee254b7db544e61d9f5ec6b42670d9a (diff)
Simplify apk build procedure when using DEPFILE
In qt6_android_add_apk_target we require that ${target} is already defined. So to add custom command that runs androiddeployqt we may simply read BINARY_DIR property of the target and use it as path to generated apk file as OUTPUT argument. This avoids the use any intermediate paths when producing apk and related artifacts. Change-Id: I8bb4174f6f9696e7a2a6b5d6399bb410419495fc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/Qt6AndroidMacros.cmake38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake
index bd60c60055..da1cfe7ece 100644
--- a/src/corelib/Qt6AndroidMacros.cmake
+++ b/src/corelib/Qt6AndroidMacros.cmake
@@ -320,13 +320,12 @@ function(qt6_android_add_apk_target target)
endif()
set(deployment_tool "${QT_HOST_PATH}/${QT6_HOST_INFO_BINDIR}/androiddeployqt")
- set(apk_final_dir "$<TARGET_PROPERTY:${target},BINARY_DIR>/android-build")
- set(apk_intermediate_dir "${CMAKE_CURRENT_BINARY_DIR}/android-build")
+ get_target_property(apk_final_dir ${target} BINARY_DIR)
+ set(apk_final_dir "${apk_final_dir}/android-build")
set(apk_file_name "${target}.apk")
set(dep_file_name "${target}.d")
set(apk_final_file_path "${apk_final_dir}/${apk_file_name}")
- set(apk_intermediate_file_path "${apk_intermediate_dir}/${apk_file_name}")
- set(dep_intermediate_file_path "${apk_intermediate_dir}/${dep_file_name}")
+ set(dep_file_path "${apk_final_dir}/${dep_file_name}")
# Temporary location of the library target file. If the library is built as an external project
# inside multi-abi build the QT_ANDROID_ABI_TARGET_PATH variable will point to the ABI related
@@ -364,33 +363,30 @@ function(qt6_android_add_apk_target target)
if(QT_ENABLE_VERBOSE_DEPLOYMENT)
list(APPEND extra_args "--verbose")
endif()
- # The DEPFILE argument to add_custom_command is only available with Ninja or CMake>=3.20 and make.
- if (CMAKE_GENERATOR MATCHES "Ninja" OR
+ # The DEPFILE argument to add_custom_command is only available with Ninja or CMake>=3.20 and
+ # make.
+ if(CMAKE_GENERATOR MATCHES "Ninja" OR
(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20 AND CMAKE_GENERATOR MATCHES "Makefiles"))
- # Add custom command that creates the apk in an intermediate location.
- # We need the intermediate location, because we cannot have target-dependent generator
- # expressions in OUTPUT.
- add_custom_command(OUTPUT "${apk_intermediate_file_path}"
+ # 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_intermediate_dir}/libs/${CMAKE_ANDROID_ARCH_ABI}/$<TARGET_FILE_NAME:${target}>"
+ "${apk_final_dir}/libs/${CMAKE_ANDROID_ARCH_ABI}/$<TARGET_FILE_NAME:${target}>"
COMMAND "${deployment_tool}"
--input "${deployment_file}"
- --output "${apk_intermediate_dir}"
- --apk "${apk_intermediate_file_path}"
- --depfile "${dep_intermediate_file_path}"
+ --output "${apk_final_dir}"
+ --apk "${apk_final_file_path}"
+ --depfile "${dep_file_path}"
--builddir "${CMAKE_BINARY_DIR}"
${extra_args}
COMMENT "Creating APK for ${target}"
DEPENDS "${target}" "${deployment_file}" ${extra_deps}
- DEPFILE "${dep_intermediate_file_path}")
+ DEPFILE "${dep_file_path}"
+ )
- # Create a ${target}_make_apk target to copy the apk from the intermediate to its final
- # location. If the final and intermediate locations are identical, this is a no-op.
- add_custom_target(${target}_make_apk
- COMMAND "${CMAKE_COMMAND}"
- -E copy_if_different "${apk_intermediate_file_path}" "${apk_final_file_path}"
- DEPENDS "${apk_intermediate_file_path}")
+ # Create a ${target}_make_apk target to trigger the apk build.
+ add_custom_target(${target}_make_apk DEPENDS "${apk_final_file_path}")
else()
add_custom_target(${target}_make_apk
DEPENDS ${target}_prepare_apk_dir