From 26f0657feedd756ed99aab4f3262c244960909d1 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 29 Mar 2023 14:20:37 +0200 Subject: [PATCH] CMake: Fix setting Android SDK/NDK from environment variables The checks for the environment variables ANDROID_SDK_ROOT and ANDROID_NDK_ROOT were guarded by if(DEFINED) conditions. However, these variables are *always* defined by the code that iterates over __qt_toolchain_used_variables earlier in the toolchain file. Change the existence checks into emptiness checks. Pick-to: 6.5 Change-Id: I6c87f86068817e45dd2325359827c6fa4dae6279 Reviewed-by: Alexandru Croitor Reviewed-by: Amir Masoud Abdol --- cmake/QtToolchainHelpers.cmake | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cmake/QtToolchainHelpers.cmake b/cmake/QtToolchainHelpers.cmake index 13b7acc0fc..ae96c5e270 100644 --- a/cmake/QtToolchainHelpers.cmake +++ b/cmake/QtToolchainHelpers.cmake @@ -222,15 +222,11 @@ set(__qt_chainload_toolchain_file \"\${__qt_initially_configured_toolchain_file} 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()" +"if(\"$\{ANDROID_SDK_ROOT}\" STREQUAL \"\" AND NOT \"\$ENV{ANDROID_SDK_ROOT}\" STREQUAL \"\")" +" set(ANDROID_SDK_ROOT \"\$ENV{ANDROID_SDK_ROOT}\" CACHE STRING \"Path to the Android SDK\")" "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()" +"if(\"$\{ANDROID_NDK_ROOT}\" STREQUAL \"\" AND NOT \"\$ENV{ANDROID_NDK_ROOT}\" STREQUAL \"\")" +" set(ANDROID_NDK_ROOT \"\$ENV{ANDROID_NDK_ROOT}\" CACHE STRING \"Path to the Android NDK\")" "endif()" )