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 <alexandru.croitor@qt.io>
(cherry picked from commit 599ad25a65ddf3b3fb7dcdc7c446da070800e507)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Cristian Le 2025-01-15 14:16:34 +01:00 committed by Qt Cherry-pick Bot
parent e120fb78c9
commit a1a77ea7d1

View File

@ -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")