CMake: Fix Android multi-abi builds in Qt Creator

Qt Creator passes -DANDROID_NDK to the main project configuration
whereas the Qt toolchain file expects -DANDROID_NDK_ROOT.

This causes the configuration of the sub-builds to fail not finding
the android toolchain, and trying to use the CI ndk toolchain path.

Make sure to consider both variables.

Also change the conditions to evaluate the variable as a variable
explicitly, to avoid passing an empty option if the variable is
unset. If the variable is unset, CMake would treat the variable as
an actual string which would always not equal the empty string.

Amends d6919b073aaae617f1ff37d18da14e315f202005

Task-number: QTBUG-104013
Task-number: QTBUG-102041
Change-Id: Ifee48953ce50bc616c49c59d72e845c6d9418187
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 5ddb13d0d4fc6d4f45dc1f0fb49ed65a299d88dd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2022-06-03 17:50:16 +02:00 committed by Qt Cherry-pick Bot
parent d8f106eab2
commit 415e37c84a

View File

@ -947,12 +947,17 @@ function(_qt_internal_configure_android_multiabi_target target)
"-DQT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH=${escaped_host_packages_prefix_path}")
endif()
if(NOT ANDROID_SDK_ROOT STREQUAL "")
if(ANDROID_SDK_ROOT)
list(APPEND extra_cmake_args "-DANDROID_SDK_ROOT=${ANDROID_SDK_ROOT}")
endif()
if(NOT ANDROID_NDK_ROOT STREQUAL "")
# ANDROID_NDK_ROOT is invented by Qt and is what the qt toolchain file expects
if(ANDROID_NDK_ROOT)
list(APPEND extra_cmake_args "-DANDROID_NDK_ROOT=${ANDROID_NDK_ROOT}")
# ANDROID_NDK is passed by Qt Creator and is also present in the android toolchain file.
elseif(ANDROID_NDK)
list(APPEND extra_cmake_args "-DANDROID_NDK_ROOT=${ANDROID_NDK}")
endif()
set(missing_qt_abi_toolchains "")