summaryrefslogtreecommitdiffstats
path: root/cmake/QtAutoDetect.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-04-22 15:07:27 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-04-23 16:50:55 +0200
commit74310cb36fe237426786bc1080e0fa5922e88cd1 (patch)
tree2faecdded4a121f93b8283ad5991c615b15887b4 /cmake/QtAutoDetect.cmake
parentff7f32f26b7e82c3dfde5530232433e616169061 (diff)
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>
Diffstat (limited to 'cmake/QtAutoDetect.cmake')
-rw-r--r--cmake/QtAutoDetect.cmake23
1 files changed, 21 insertions, 2 deletions
diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake
index 15d0db42c4..706ffe6aea 100644
--- a/cmake/QtAutoDetect.cmake
+++ b/cmake/QtAutoDetect.cmake
@@ -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()