diff --git a/CMakeLists.txt b/CMakeLists.txt index f453505ee8..c272ab6f05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,7 +117,7 @@ if(NOT QT_BUILD_STANDALONE_TESTS) # Needed when building qtbase for android. if(ANDROID) include(src/corelib/Qt6AndroidMacros.cmake) - _qt_internal_create_global_apk_target() + _qt_internal_create_global_android_targets() endif() if(WASM) diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index a8843e4675..9495be94e5 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -322,9 +322,10 @@ function(qt6_android_add_apk_target target) message(FATAL_ERROR "Target ${target} is not a valid android executable target\n") endif() - # Make global apk target depend on the current apk target. + # Make global apk and aab targets depend on the current apk target. if(TARGET apk) add_dependencies(apk ${target}_make_apk) + add_dependencies(aab ${target}_make_aab) _qt_internal_create_global_apk_all_target_if_needed() endif() @@ -407,19 +408,44 @@ function(qt6_android_add_apk_target target) COMMENT "Creating APK for ${target}" ) endif() + + # Add target triggering AAB creation. Since the _make_aab target is not added to the ALL + # set, we may avoid dependency check for it and admit that the target is "always out + # of date". + add_custom_target(${target}_make_aab + DEPENDS ${target}_prepare_apk_dir + COMMAND ${deployment_tool} + --input ${deployment_file} + --output ${apk_final_dir} + --apk ${apk_final_file_path} + --aab + ${extra_args} + COMMENT "Creating AAB for ${target}" + ) + set_property(GLOBAL APPEND PROPERTY _qt_apk_targets ${target}) _qt_internal_collect_target_apk_dependencies_defer(${target}) endfunction() -function(_qt_internal_create_global_apk_target) +function(_qt_internal_create_global_android_targets) + macro(_qt_internal_create_global_android_targets_impl target) + string(TOUPPER "${target}" target_upper) + if(NOT QT_NO_GLOBAL_${target_upper}_TARGET) + if(NOT TARGET ${target}) + add_custom_target(${target} COMMENT "Building all apks") + endif() + endif() + endmacro() + # 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) - add_custom_target(apk COMMENT "Building all apks") - endif() - endif() + _qt_internal_create_global_android_targets_impl(apk) + + # Create a top-level "aab" target for convenience, so that users can call 'ninja aab'. + # It will trigger building all the apk build targets that are added as part of the project. + # Allow opting out. + _qt_internal_create_global_android_targets_impl(aab) endfunction() # The function collects all known non-imported shared libraries that are created in the build tree. diff --git a/src/corelib/Qt6CoreConfigExtras.cmake.in b/src/corelib/Qt6CoreConfigExtras.cmake.in index acde0b98f2..6ceb4b201f 100644 --- a/src/corelib/Qt6CoreConfigExtras.cmake.in +++ b/src/corelib/Qt6CoreConfigExtras.cmake.in @@ -46,7 +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() + _qt_internal_create_global_android_targets() _qt_internal_collect_default_android_abis() endif()