summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-11-09 15:11:15 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-11-10 14:23:09 +0100
commit3792b55022d1d6171f77d283d6e08fd868d58718 (patch)
treea69902d7f3f48a0be416b0fba9000b4d26650eac
parentba6175eb731927f2489cdd7d899616a9889aba67 (diff)
CMake: Fix qtbase cmake tests to pass when configured in-tree
As opposed to standalone tests. The problem is that 4 of the cmake failbuild tests use try_compile as an indirection layer to configure /another/ project which is actually the test. That project needs to know the location of Qt. To do that, a FindPackageHints.cmake file is included and the variable it sets is passed to find_package() HINTS option. That's enough to find a specific module, but not any dependent Tools packages. Work around that by adding the Qt location to CMAKE_PREFIX_PATH in the included FindPackageHints.cmake file. The problem does not happen in standalone tests, because the Qt location ends up being propagated via the qt toolchain file, which does get inherited by the compile tests (albeit in a weird way, where a reconfiguration still shows CMAKE_PREFIX_PATH to be empty). Change-Id: I1f7ce940fd31678b46c0356edf6581e523cb885a Fixes: QTBUG-86963 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/corelib/Qt6CTestMacros.cmake5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/Qt6CTestMacros.cmake b/src/corelib/Qt6CTestMacros.cmake
index 2e0ea919ad..50cc40939a 100644
--- a/src/corelib/Qt6CTestMacros.cmake
+++ b/src/corelib/Qt6CTestMacros.cmake
@@ -143,7 +143,10 @@ macro(_qt_internal_test_expect_fail _dir)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}")
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/${_dir}/FindPackageHints.cmake" "set(Qt6Tests_PREFIX_PATH \"${CMAKE_PREFIX_PATH}\")")
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/${_dir}/FindPackageHints.cmake"
+ "set(Qt6Tests_PREFIX_PATH \"${CMAKE_PREFIX_PATH}\")
+list(APPEND CMAKE_PREFIX_PATH \"${CMAKE_PREFIX_PATH}\")
+")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/CMakeLists.txt"
"