diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-06-07 17:14:39 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-08 21:48:47 +0000 |
commit | c5c2ca9e2289a4cfe1072abd737a06bae0de5e4a (patch) | |
tree | 7fe1867cba8ae3c74b0622fa6f090e19cca7d4c7 /src | |
parent | 294b50e1f5c388f666d10febe3fcc024d1d13c24 (diff) |
CMake: Fix global 'apk' target to actually build all apks
This means calling 'ninja apk' in a user project with multiple android
applications will build all their respective apks.
For user projects, make the 'apk' target part of the global 'ALL'
target, so that a regular 'ninja' call implies the 'apk' target.
We don't do it currently for Qt builds, because certain test
executable apks fail to build.
Add a QT_NO_GLOBAL_APK_TARGET_PART_OF_ALL variable to allow removing
the global apk target from the 'all' target.
Task-number: QTBUG-94264
Change-Id: I171b9da50eb7d670176704bd26dc1c492118b434
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 8b8679f73d6cfb513141cc0a9f4925a64ca19455)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/Qt6AndroidMacros.cmake | 40 | ||||
-rw-r--r-- | src/corelib/Qt6CoreConfigExtras.cmake.in | 1 |
2 files changed, 30 insertions, 11 deletions
diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index 556300125c..7d4fee3ffc 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -281,17 +281,9 @@ function(qt6_android_add_apk_target target) message(FATAL_ERROR "Target ${target} is not a valid android executable target\n") endif() - # Create a top-level "apk" target for convenience, so that users can call 'ninja apk'. - # It will trigger building all the target specific apk build targets that are added via this - # function. - # Allow opt-out. - if(NOT QT_NO_GLOBAL_APK_TARGET) - if(NOT TARGET apk) - add_custom_target(apk - DEPENDS ${target}_make_apk - COMMENT "Building all apks" - ) - endif() + # Make global apk target depend on the current apk target. + if(TARGET apk) + add_dependencies(apk ${target}_make_apk) endif() set(deployment_tool "${QT_HOST_PATH}/${QT6_HOST_INFO_BINDIR}/androiddeployqt") @@ -332,6 +324,32 @@ function(qt6_android_add_apk_target target) DEPENDS "${apk_intermediate_file_path}") endfunction() +function(_qt_internal_create_global_apk_target) + # Create a top-level "apk" target for convenience, so that users can call 'ninja apk'. + # It will trigger building all the apk build targets that are added as part of the project. + # Allow opting out. + if(NOT QT_NO_GLOBAL_APK_TARGET) + if(NOT TARGET apk) + # Some Qt tests helper executables have their apk build process failing. + # Don't build apks by default when doing a Qt build. + set(skip_add_to_all FALSE) + if(QT_BUILDING_QT) + set(skip_add_to_all TRUE) + endif() + + option(QT_NO_GLOBAL_APK_TARGET_PART_OF_ALL + "Skip building apks as part of the default 'ALL' target" ${skip_add_to_all}) + + set(part_of_all "ALL") + if(QT_NO_GLOBAL_APK_TARGET_PART_OF_ALL) + set(part_of_all "") + endif() + + add_custom_target(apk ${part_of_all} COMMENT "Building all apks") + endif() + endif() +endfunction() + if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) function(qt_android_add_apk_target) qt6_android_add_apk_target(${ARGV}) diff --git a/src/corelib/Qt6CoreConfigExtras.cmake.in b/src/corelib/Qt6CoreConfigExtras.cmake.in index e7892bbcc3..edfda9541c 100644 --- a/src/corelib/Qt6CoreConfigExtras.cmake.in +++ b/src/corelib/Qt6CoreConfigExtras.cmake.in @@ -46,4 +46,5 @@ set(_Qt6CTestMacros "${_Qt6CoreConfigDir}/Qt6CTestMacros.cmake") if(ANDROID_PLATFORM) include("${CMAKE_CURRENT_LIST_DIR}/@QT_CMAKE_EXPORT_NAMESPACE@AndroidMacros.cmake") + _qt_internal_create_global_apk_target() endif() |