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

Users may add the implicit runtime depedencies to the MODULE_LIBRARY
targets, that are created using standard CMake API. When iterating a
project tree we collect all module libraries and add them as
dependencies to the qt_internal_plugins meta target. All the
${target}_make_apk targets depend on this meta target, so we can
be sure that plugins are built and present on the file system before
running androiddeployqt.

Task-number: QTBUG-94714
Task-number: QTBUG-88841
Change-Id: I4fa7f0772d23897f19db59c6e4ad38646bd3aed6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2021-11-04 16:40:30 +01:00
parent 067a23f2c6
commit 45ce3c6fb9

View File

@ -469,9 +469,21 @@ function(_qt_internal_collect_target_apk_dependencies target)
_qt_internal_collect_buildsystem_shared_libraries(libs "${CMAKE_SOURCE_DIR}")
if(NOT TARGET qt_internal_plugins)
add_custom_target(qt_internal_plugins)
endif()
foreach(lib IN LISTS libs)
if(NOT lib IN_LIST apk_targets)
list(APPEND extra_prefix_dirs "$<TARGET_FILE_DIR:${lib}>")
get_target_property(target_type ${lib} TYPE)
# We collect all MODULE_LIBRARY targets since target APK may have implicit dependency
# to the plugin that will cause the runtime issue. Plugins that were added using
# qt6_add_plugin should be already added to the qt_internal_plugins dependency list,
# but it's ok to re-add them.
if(target_type STREQUAL "MODULE_LIBRARY")
add_dependencies(qt_internal_plugins ${lib})
endif()
endif()
endforeach()