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 8b8679f73d
Pick-to: 6.2 6.1
Fixes: QTBUG-94442
Task-number: QTBUG-94264
Change-Id: I92ff0a7eef2caad244340ab7835e77c9fb3377c0
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
d245e3a788
commit
1d05dcb3ec
@ -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})
|
||||
|
Loading…
Reference in New Issue
Block a user