summaryrefslogtreecommitdiffstats
path: root/cmake/QtToolchainHelpers.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2020-11-04 14:39:52 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2020-11-05 13:04:56 +0100
commitca59c20939a09587662fa8fecd4e480b68244541 (patch)
treec48a2ce6e5492bc1f6bb7ca5b187cbe29030a889 /cmake/QtToolchainHelpers.cmake
parent48faa8ed5a34f0780cded4546547cee96fc1dc2f (diff)
CMake: Fix usage of cache variables in qt.toolchain.cmake
We have some cache variables that are used in our qt.toolchain.cmake toolchain file, for example QT_CHAINLOAD_TOOLCHAIN_FILE. When CMake runs a configure test with try_compile, our toolchain file is included again, but only a restricted set of variables is available. Add the variables that are used in our internal toolchain file to CMAKE_TRY_COMPILE_PLATFORM_VARIABLES. This makes them visible for try_compile calls operating on source files. Also pass the variables via the environment to support try_compile calls that operate on whole projects. Fixes: QTBUG-87873 Change-Id: Iebca9e23686bec5072194b15482e1782b9367a0e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtToolchainHelpers.cmake')
-rw-r--r--cmake/QtToolchainHelpers.cmake8
1 files changed, 8 insertions, 0 deletions
diff --git a/cmake/QtToolchainHelpers.cmake b/cmake/QtToolchainHelpers.cmake
index 2593aa7429..a0897696bd 100644
--- a/cmake/QtToolchainHelpers.cmake
+++ b/cmake/QtToolchainHelpers.cmake
@@ -95,6 +95,7 @@ function(qt_internal_create_toolchain_file)
endif()")
endif()
+ unset(init_additional_used_variables)
if(APPLE)
# For simulator_and_device build, we should not explicitly set the sysroot.
list(LENGTH CMAKE_OSX_ARCHITECTURES _qt_osx_architectures_count)
@@ -125,6 +126,11 @@ function(qt_internal_create_toolchain_file)
list(APPEND init_platform "endif()")
endif()
elseif(ANDROID)
+ foreach(var ANDROID_NATIVE_API_LEVEL ANDROID_STL ANDROID_ABI
+ ANDROID_SDK_ROOT ANDROID_NDK_ROOT)
+ list(APPEND init_additional_used_variables
+ "list(APPEND __qt_toolchain_used_variables ${var})")
+ endforeach()
list(APPEND init_platform
"set(ANDROID_NATIVE_API_LEVEL \"${ANDROID_NATIVE_API_LEVEL}\" CACHE STRING \"\")")
list(APPEND init_platform "set(ANDROID_STL \"${ANDROID_STL}\" CACHE STRING \"\")")
@@ -151,6 +157,8 @@ function(qt_internal_create_toolchain_file)
list(APPEND init_platform "endif()")
endif()
+ string(REPLACE ";" "\n" init_additional_used_variables
+ "${init_additional_used_variables}")
string(REPLACE ";" "\n" init_vcpkg "${init_vcpkg}")
string(REPLACE ";" "\n" init_platform "${init_platform}")
string(REPLACE "LITERAL_SEMICOLON" ";" init_platform "${init_platform}")