diff options
author | Andreas Buhr <andreas.buhr@qt.io> | 2021-06-18 15:09:58 +0200 |
---|---|---|
committer | Andreas Buhr <andreas.buhr@qt.io> | 2021-07-08 17:30:20 +0200 |
commit | 857be50b2e193b92de37c3e2bb5124d24d21a253 (patch) | |
tree | b446bb5df0b8362dd807cb1bab287b4edfa5a156 /src/corelib/Qt6AndroidMacros.cmake | |
parent | 85e25d93b3b99fbeae8541586252df2cb099081d (diff) |
Let androiddeployqt write a dependency file
Let androiddeployqt write a dependency file so that
the build system knows when to re-run it.
Fixes: QTBUG-94567
Change-Id: I5985d707f257b22789013a74f0a6f7c4de6e5e88
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/corelib/Qt6AndroidMacros.cmake')
-rw-r--r-- | src/corelib/Qt6AndroidMacros.cmake | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index b7d2490522..e37ce287bd 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -291,10 +291,13 @@ function(qt6_android_add_apk_target target) set(apk_final_dir "$<TARGET_PROPERTY:${target},BINARY_DIR>/android-build") set(apk_intermediate_dir "${CMAKE_CURRENT_BINARY_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}") - # This target is used by Qt Creator's Android support. + # This target is used by Qt Creator's Android support and by the ${target}_make_apk target + # in case DEPFILEs are not supported. add_custom_target(${target}_prepare_apk_dir ALL DEPENDS ${target} COMMAND ${CMAKE_COMMAND} @@ -303,26 +306,42 @@ function(qt6_android_add_apk_target target) COMMENT "Copying ${target} binary to apk folder" ) - # 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}" - COMMAND ${CMAKE_COMMAND} - -E copy "$<TARGET_FILE:${target}>" - "${apk_intermediate_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}" - COMMENT "Creating APK for ${target}" - DEPENDS "${target}" "${deployment_file}") - - # 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}") + # 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}" + COMMAND ${CMAKE_COMMAND} + -E copy "$<TARGET_FILE:${target}>" + "${apk_intermediate_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}" + --builddir "${CMAKE_BINARY_DIR}" + COMMENT "Creating APK for ${target}" + DEPENDS "${target}" "${deployment_file}" + DEPFILE "${dep_intermediate_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}") + else() + add_custom_target(${target}_make_apk + DEPENDS ${target}_prepare_apk_dir + COMMAND ${deployment_tool} + --input ${deployment_file} + --output ${apk_final_dir} + --apk ${apk_final_file_path} + COMMENT "Creating APK for ${target}" + ) + endif() endfunction() function(_qt_internal_create_global_apk_target) |