From a1a77ea7d13bb1a47956a518815582f3858e48dc Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Wed, 15 Jan 2025 14:16:34 +0100 Subject: [PATCH] Forward `find_package` hints to auto/cmake If the tests are built and run as standalone or non-prefix build and a find hint was used, e.g. `Qt6_ROOT`, then this type hint should be forwarded to the `ctest --build-and-test` otherwise the internal package would fail when it tries to `find_package`. Change-Id: If71852dd5124b8deeddd28ba835f1943d96ba2b8 Reviewed-by: Alexandru Croitor (cherry picked from commit 599ad25a65ddf3b3fb7dcdc7c446da070800e507) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/Qt6CTestMacros.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/Qt6CTestMacros.cmake b/src/corelib/Qt6CTestMacros.cmake index 084959db49a..939901f5e20 100644 --- a/src/corelib/Qt6CTestMacros.cmake +++ b/src/corelib/Qt6CTestMacros.cmake @@ -142,6 +142,13 @@ function(_qt_internal_get_cmake_test_configure_options out_var) list(APPEND option_list "-DQT_BUILD_DIR=${QT_BUILD_DIR}") endif() + # Forward whatever hints were used in find_package(Qt6) to the ctest configure + foreach(hint IN ITEMS Qt6_ROOT QT6_ROOT) + if(DEFINED ${hint}) + list(APPEND option_list "-D${hint}=${${hint}}") + endif() + endforeach() + # Pass a variable that can serve as a marker for cmake build tests in other build system code. list(APPEND option_list "-DQT_INTERNAL_IS_CMAKE_BUILD_TEST=ON")