Skip to content

Commit

Permalink
Android: use latest platform only if the default is not found
Browse files Browse the repository at this point in the history
We initially set a value to QT_ANDROID_API_USED_FOR_JAVA as the
default supported version, so consistently use that unless it's
not found at which case try to take the latest found version.

Task-number: QTBUG-128364
Change-Id: I5e8404887b1649aad3ae37d2352e3ca099392935
Reviewed-by: Lars Schmertmann <[email protected]>
Reviewed-by: Alexey Edelev <[email protected]>
  • Loading branch information
Issam-b committed Dec 7, 2024
1 parent faec1a0 commit 953b7aa
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions cmake/QtPlatformAndroid.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ if (NOT IS_DIRECTORY "${ANDROID_SDK_ROOT}")
message(FATAL_ERROR "Could not find ANDROID_SDK_ROOT or path is not a directory: ${ANDROID_SDK_ROOT}")
endif()

# This variable specifies the API level used for building Java code, it can be the same as Qt for
# Android's maximum supported Android version or higher.
set(QT_ANDROID_API_USED_FOR_JAVA "android-34")

function(qt_internal_sort_android_platforms out_var)
if(CMAKE_VERSION GREATER_EQUAL 3.18)
set(platforms ${ARGN})
Expand Down Expand Up @@ -54,18 +50,18 @@ function(qt_internal_sort_android_platforms out_var)
set("${out_var}" "${platforms}" PARENT_SCOPE)
endfunction()

macro(qt_internal_get_android_platform_version out_var android_platform)
string(REGEX REPLACE ".*-([0-9]+)$" "\\1" ${out_var} "${android_platform}")
endmacro()

_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
"${QT_ANDROID_API_USED_FOR_JAVA}")
# This variable specifies the API level used for building Java code, it can be the same as Qt for
# Android's maximum supported Android version or higher.
if(NOT QT_ANDROID_API_USED_FOR_JAVA)
set(QT_ANDROID_API_USED_FOR_JAVA "android-34")
endif()

if("${latest_platform_version}" VERSION_GREATER "${required_platform_version}")
set(jar_location "${ANDROID_SDK_ROOT}/platforms/${QT_ANDROID_API_USED_FOR_JAVA}/android.jar")
if(NOT EXISTS "${jar_location}")
_qt_internal_detect_latest_android_platform(android_platform_latest)
if(android_platform_latest)
message(NOTICE "The default platform SDK ${QT_ANDROID_API_USED_FOR_JAVA} not found, "
"using the latest installed ${android_platform_latest} instead.")
set(QT_ANDROID_API_USED_FOR_JAVA ${android_platform_latest})
endif()
endif()
Expand Down

0 comments on commit 953b7aa

Please sign in to comment.