From a42e7839b27c9fc29fc0b37c342c8c489d445219 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Fri, 1 Apr 2022 16:17:55 +0200 Subject: [PATCH] Make possible to set android SDK/NDK roots from environment Read the ANDROID__ROOT environment variables in qt toolchain file and use them to chainload the android toolchain file. Pick-to: 6.2 6.3 Change-Id: I1940ffbaa557974fc26005f4d051030f2cc5c7e0 Reviewed-by: Alexandru Croitor --- cmake/QtToolchainHelpers.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmake/QtToolchainHelpers.cmake b/cmake/QtToolchainHelpers.cmake index f7ea59d1b59..a674973f4da 100644 --- a/cmake/QtToolchainHelpers.cmake +++ b/cmake/QtToolchainHelpers.cmake @@ -184,6 +184,20 @@ set(__qt_chainload_toolchain_file \"\${__qt_initially_configured_toolchain_file} list(APPEND init_platform "endif()") endif() elseif(ANDROID) + list(APPEND init_platform +"# Detect Android SDK/NDK from environment before loading the Android platform toolchain file." +"if(NOT DEFINED ANDROID_SDK_ROOT)" +" if(NOT \"\$ENV{ANDROID_SDK_ROOT}\" STREQUAL \"\")" +" set(ANDROID_SDK_ROOT \"\$ENV{ANDROID_SDK_ROOT}\" CACHE STRING \"Path to the Android SDK\")" +" endif()" +"endif()" +"if(NOT DEFINED ANDROID_NDK_ROOT)" +" if(NOT \"\$ENV{ANDROID_NDK_ROOT}\" STREQUAL \"\")" +" set(ANDROID_NDK_ROOT \"\$ENV{ANDROID_NDK_ROOT}\" CACHE STRING \"Path to the Android NDK\")" +" endif()" +"endif()" + ) + foreach(var ANDROID_PLATFORM ANDROID_NATIVE_API_LEVEL ANDROID_STL ANDROID_ABI ANDROID_SDK_ROOT ANDROID_NDK_ROOT) list(APPEND init_additional_used_variables