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. Pick-to: 6.1 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>
This commit is contained in:
parent
9b625ec89d
commit
8b8679f73d
@ -106,7 +106,10 @@ if(NOT QT_BUILD_STANDALONE_TESTS)
|
||||
include(src/corelib/Qt6CoreMacros.cmake)
|
||||
|
||||
# Needed when building qtbase for android.
|
||||
if(ANDROID)
|
||||
include(src/corelib/Qt6AndroidMacros.cmake)
|
||||
_qt_internal_create_global_apk_target()
|
||||
endif()
|
||||
|
||||
if(WASM)
|
||||
# Needed when building for WebAssembly.
|
||||
|
@ -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})
|
||||
|
@ -46,6 +46,7 @@ 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()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
|
Loading…
Reference in New Issue
Block a user