diff --git a/cmake/QtBuildHelpers.cmake b/cmake/QtBuildHelpers.cmake index 5032745034b..79d47d87378 100644 --- a/cmake/QtBuildHelpers.cmake +++ b/cmake/QtBuildHelpers.cmake @@ -280,6 +280,7 @@ function(qt_internal_get_qt_build_public_helpers out_var) set(${out_var} QtFeature QtFeatureCommon + QtPublicAndroidHelpers QtPublicAppleHelpers QtPublicCMakeHelpers QtPublicCMakeVersionHelpers diff --git a/cmake/QtPlatformAndroid.cmake b/cmake/QtPlatformAndroid.cmake index a149ea296c9..ee3214e907b 100644 --- a/cmake/QtPlatformAndroid.cmake +++ b/cmake/QtPlatformAndroid.cmake @@ -70,17 +70,8 @@ macro(qt_internal_get_android_platform_version out_var android_platform) string(REGEX REPLACE ".*-([0-9]+)$" "\\1" ${out_var} "${android_platform}") endmacro() -# Locate the highest available platform -file(GLOB android_platforms - LIST_DIRECTORIES true - RELATIVE "${ANDROID_SDK_ROOT}/platforms" - "${ANDROID_SDK_ROOT}/platforms/*") -# If list is not empty -if(android_platforms) - qt_internal_sort_android_platforms(android_platforms ${android_platforms}) - list(REVERSE android_platforms) - list(GET android_platforms 0 android_platform_latest) - +_qt_internal_detect_latest_android_platform(android_platform_latest) +if(android_platform_latest) qt_internal_get_android_platform_version(latest_platform_version "${android_platform_latest}") qt_internal_get_android_platform_version(required_platform_version diff --git a/cmake/QtPublicAndroidHelpers.cmake b/cmake/QtPublicAndroidHelpers.cmake new file mode 100644 index 00000000000..dd50c011d3e --- /dev/null +++ b/cmake/QtPublicAndroidHelpers.cmake @@ -0,0 +1,20 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +function(_qt_internal_detect_latest_android_platform out_var) + # Locate the highest available platform + file(GLOB android_platforms + LIST_DIRECTORIES true + RELATIVE "${ANDROID_SDK_ROOT}/platforms" + "${ANDROID_SDK_ROOT}/platforms/*") + + # If list is not empty + if(android_platforms) + qt_internal_sort_android_platforms(android_platforms ${android_platforms}) + list(REVERSE android_platforms) + list(GET android_platforms 0 android_platform_latest) + set(${out_var} "${android_platform_latest}" PARENT_SCOPE) + else() + set(${out_var} "${out_var}-NOTFOUND" PARENT_SCOPE) + endif() +endfunction()