Make sure that all plugin targets are built before deploying to Android

We need to make sure that all plugin targets are built and present
on the file system before running androiddeployqt. This especially
important when building executables that depend on qml modules that are
built in the project tree. This adds meta target that collects all
the plugin targets as dependencies and adds this meta target as the
dependency for the custom target that executes androiddeployqt.

TODO: We should also take into account MODULE libraries that were
added using the CMake add_library call, but since qt6_finalize_project
is not a part of 6.2 API, this will be added in follow up commit.

Pick-to: 6.2
Task-number: QTBUG-94714
Task-number: QTBUG-88841
Change-Id: I4b4596eb8ed364dbe80e2cfb0ce31cec32e7c03f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
bb10
Alexey Edelev 2021-11-04 16:08:34 +01:00
parent 2c070b6f4d
commit 067a23f2c6
2 changed files with 19 additions and 2 deletions

View File

@ -339,8 +339,18 @@ function(qt6_android_add_apk_target target)
# in case DEPFILEs are not supported.
# Also the target is used to copy the library that belongs to ${target} when building multi-abi
# apk to the abi-specific directory.
set(extra_deps "")
# Plugins still might be added after creating the deployment targets.
if(NOT TARGET qt_internal_plugins)
add_custom_target(qt_internal_plugins)
endif()
# Before running androiddeployqt, we need to make sure all plugins are built.
list(APPEND extra_deps qt_internal_plugins)
add_custom_target(${target}_prepare_apk_dir ALL
DEPENDS ${target}
DEPENDS ${target} ${extra_deps}
COMMAND ${CMAKE_COMMAND}
-E copy_if_different $<TARGET_FILE:${target}>
"${copy_target_path}/$<TARGET_FILE_NAME:${target}>"
@ -372,7 +382,7 @@ function(qt6_android_add_apk_target target)
--builddir "${CMAKE_BINARY_DIR}"
${extra_args}
COMMENT "Creating APK for ${target}"
DEPENDS "${target}" "${deployment_file}"
DEPENDS "${target}" "${deployment_file}" ${extra_deps}
DEPFILE "${dep_intermediate_file_path}")
# Create a ${target}_make_apk target to copy the apk from the intermediate to its final

View File

@ -2129,6 +2129,13 @@ function(qt6_add_plugin target)
QT_PLUGIN
QT_DEPRECATED_WARNINGS
)
if(target_type STREQUAL "MODULE_LIBRARY")
if(NOT TARGET qt_internal_plugins)
add_custom_target(qt_internal_plugins)
endif()
add_dependencies(qt_internal_plugins ${target})
endif()
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)