CMake: Fix global 'apk' target to apply to Qt EXTERNAL_BUILD examples

This means calling 'ninja apk' in a Qt build with examples configured
will build all example apks, regardless of whether the examples are
built as external projects or in-tree.

Fixes: QTBUG-94264
Change-Id: I5c7af0354858898a2e154a6d54fb025e4d81ff80
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2021-06-07 17:14:39 +02:00
parent 8b8679f73d
commit 524b957d1f

View File

@ -905,6 +905,23 @@ function(qt_internal_add_example subdir)
${independent_args}
)
# Create an apk external project step and custom target that invokes the apk target
# within the external project.
# Make the global apk target depend on that custom target.
if(ANDROID)
ExternalProject_Add_Step(${arg_NAME} apk
COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target apk
DEPENDEES configure
EXCLUDE_FROM_MAIN YES
${terminal_args}
)
ExternalProject_Add_StepTargets(${arg_NAME} apk)
if(TARGET apk)
add_dependencies(apk ${arg_NAME}-apk)
endif()
endif()
cmake_policy(POP)
string(TOLOWER ${PROJECT_NAME} project_name_lower)