Android: Choose latest version when autodetecting the NDK
Before, we relied on the deprecated "ndk-bundle" subdirectory being present in the SDK root. Now, we choose the NDK with the latest version in the SDK's ndk subdirectory. Pick-to: 6.1 Fixes: QTBUG-87579 Change-Id: I37a9e03184f4518b4074d55375af08209591de94 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
ff7f32f26b
commit
74310cb36f
@ -106,8 +106,27 @@ endfunction()
|
||||
function(qt_auto_detect_android)
|
||||
# Auto-detect NDK root
|
||||
if(NOT DEFINED ANDROID_NDK_ROOT AND DEFINED ANDROID_SDK_ROOT)
|
||||
set(ndk_root "${ANDROID_SDK_ROOT}/ndk-bundle")
|
||||
if(IS_DIRECTORY "${ndk_root}")
|
||||
file(GLOB ndk_versions LIST_DIRECTORIES true RELATIVE "${ANDROID_SDK_ROOT}/ndk"
|
||||
"${ANDROID_SDK_ROOT}/ndk/*")
|
||||
unset(ndk_root)
|
||||
if(NOT ndk_versions STREQUAL "")
|
||||
# Use the NDK with the highest version number.
|
||||
if(CMAKE_VERSION VERSION_LESS 3.18)
|
||||
list(SORT ndk_versions)
|
||||
list(REVERSE ndk_versions)
|
||||
else()
|
||||
list(SORT ndk_versions COMPARE NATURAL ORDER DESCENDING)
|
||||
endif()
|
||||
list(GET ndk_versions 0 ndk_root)
|
||||
string(PREPEND ndk_root "${ANDROID_SDK_ROOT}/ndk/")
|
||||
else()
|
||||
# Fallback: use the deprecated "ndk-bundle" directory within the SDK root.
|
||||
set(ndk_root "${ANDROID_SDK_ROOT}/ndk-bundle")
|
||||
if(NOT IS_DIRECTORY "${ndk_root}")
|
||||
unset(ndk_root)
|
||||
endif()
|
||||
endif()
|
||||
if(DEFINED ndk_root)
|
||||
message(STATUS "Android NDK detected: ${ndk_root}")
|
||||
set(ANDROID_NDK_ROOT "${ndk_root}" CACHE STRING "")
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user