From f917df27520874e5645ac51a1f65aae4a2375ce5 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 22 Oct 2021 12:20:19 +0200 Subject: [PATCH] CMake: Fix _QT_TOOLCHAIN_VARS_INITIALIZED check in toolchain file The environment variable check to set extra env vars was using invalid syntax. The condition always resolved to TRUE which means the env vars were constantly re-assigned inside each try_compile project. To check for undefined-ness, one can use if(NOT DEFINED ENV{...}) To check for false-ness, one can use if(NOT "$ENV{...}") To check for string emptiness, one can use if(NOT "$ENV{...}" STREQUAL "") In this particular case checking for false-ness is good enough. The extra re-assigning had no visible effect, so this is just cleanup. As a drive-by, clarify one comment. Amends ca59c20939a09587662fa8fecd4e480b68244541 Pick-to: 6.2 Change-Id: I8fd400101efa9e610a81268c33cac8c0cb33cba3 Reviewed-by: Alexey Edelev Reviewed-by: Craig Scott --- cmake/qt.toolchain.cmake.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in index d5fc183c74..5e9acd66b8 100644 --- a/cmake/qt.toolchain.cmake.in +++ b/cmake/qt.toolchain.cmake.in @@ -197,9 +197,9 @@ if(__qt_toolchain_host_path_required AND endif() # Compile tests only see a restricted set of variables. -# All cache variables, this toolchain file uses, must be made available to compile tests, -# because this toolchain file will be included there too. -if(NOT ENV{_QT_TOOLCHAIN_VARS_INITIALIZED}) +# All cache variables, this toolchain file uses, must be made available to project-based +# try_compile tests because this toolchain file will be included there too. +if(NOT "$ENV{_QT_TOOLCHAIN_VARS_INITIALIZED}") set(ENV{_QT_TOOLCHAIN_VARS_INITIALIZED} ON) foreach(var ${__qt_toolchain_used_variables}) set(ENV{_QT_TOOLCHAIN_${var}} "${${var}}")