summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-06-11 12:46:36 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-06-11 19:23:03 +0200
commit1d05dcb3ec677a301a5a626384b2bf8003af2663 (patch)
treea5c32c571601453de2c764a8e1533e114eb3515b /src/corelib
parentd245e3a7883ccb2c8beabbca5094de54ec963644 (diff)
CMake: Fix Qt tool apks not to be built as part of default all target
The code already checked for QT_BUILDING_QT to decide whether the 'apk' target should be part of the default 'all' target, but it only worked properly for qtbase. The 'apk' target was created before the value of QT_BUILDING_QT is set when building other repos like qttools. Postpone the decision on whether 'apk' should be part of 'all' to the first call of qt_add_executable -> qt_android_add_apk_target. At this point QT_BUILDING_QT will be defined. Achieve that by relying on an additional 'apk_all' target as an implementation detail. Amends 8b8679f73d6cfb513141cc0a9f4925a64ca19455 Pick-to: 6.2 6.1 Fixes: QTBUG-94442 Task-number: QTBUG-94264 Change-Id: I92ff0a7eef2caad244340ab7835e77c9fb3377c0 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt6AndroidMacros.cmake51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake
index 80baaed68e..b7d2490522 100644
--- a/src/corelib/Qt6AndroidMacros.cmake
+++ b/src/corelib/Qt6AndroidMacros.cmake
@@ -284,6 +284,7 @@ function(qt6_android_add_apk_target target)
# Make global apk target depend on the current apk target.
if(TARGET apk)
add_dependencies(apk ${target}_make_apk)
+ _qt_internal_create_global_apk_all_target_if_needed()
endif()
set(deployment_tool "${QT_HOST_PATH}/${QT6_HOST_INFO_BINDIR}/androiddeployqt")
@@ -330,26 +331,44 @@ function(_qt_internal_create_global_apk_target)
# 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")
+ add_custom_target(apk COMMENT "Building all apks")
endif()
endif()
endfunction()
+# This function allows deciding whether apks should be built as part of the ALL target at first
+# add_executable call point, rather than when the 'apk' target is created as part of the
+# find_package(Core) call.
+#
+# It does so by creating a custom 'apk_all' target as an implementation detail.
+#
+# This is needed to ensure that the decision is made only when the value of QT_BUILDING_QT is
+# available, which is defined in qt_repo_build() -> include(QtSetup), which is included after the
+# execution of _qt_internal_create_global_apk_target.
+function(_qt_internal_create_global_apk_all_target_if_needed)
+ if(TARGET apk AND NOT TARGET apk_all)
+ # Some Qt tests helper executables have their apk build process failing.
+ # qt_internal_add_executables that are excluded from ALL should also not have apks built
+ # for them.
+ # 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_all ${part_of_all})
+ add_dependencies(apk_all apk)
+ endif()
+endfunction()
+
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
function(qt_android_add_apk_target)
qt6_android_add_apk_target(${ARGV})