CMake: Allow find_package(Qt6 COMPONENTS Foo) in tests
In prefix builds of non-qtbase repositories, calls to find_package(Qt6
COMPONENT Foo) did not work in tests, because the find_package calls in
Qt6Config.cmake use NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH is
ignored.
Non-external-project examples had the same problem. This was fixed by
ffe0889413
which introduced the variable
QT_EXAMPLES_CMAKE_PREFIX_PATH as additional parameter in all relevant
find_package calls.
We now set this variable in qt_build_tests where it should be local to
the tests directory and its children.
We cannot use QT_ADDITIONAL_PACKAGES_PREFIX_PATH, because it's value is
read once and cached in Qt6Config.cmake - we would have to clear the
internal cache variable.
It would probably be good to rename QT_EXAMPLES_CMAKE_PREFIX_PATH to
reflect that it's not just used for examples. However, my naming skills
are drained for today.
Task-number: QTBUG-88264
Change-Id: I8bcfe9b7f2ee1f1b75dc725977924d09cb36822c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
b684984939
commit
2ab80a2c18
@ -717,6 +717,10 @@ endfunction()
|
|||||||
macro(qt_build_tests)
|
macro(qt_build_tests)
|
||||||
set(CMAKE_UNITY_BUILD OFF)
|
set(CMAKE_UNITY_BUILD OFF)
|
||||||
|
|
||||||
|
# Prepending to QT_EXAMPLES_CMAKE_PREFIX_PATH helps find components of Qt6, because those
|
||||||
|
# find_package calls use NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH is ignored.
|
||||||
|
list(PREPEND QT_EXAMPLES_CMAKE_PREFIX_PATH "${QT_BUILD_DIR}/${INSTALL_LIBDIR}/cmake")
|
||||||
|
|
||||||
if(QT_BUILD_STANDALONE_TESTS)
|
if(QT_BUILD_STANDALONE_TESTS)
|
||||||
# Find location of TestsConfig.cmake. These contain the modules that need to be
|
# Find location of TestsConfig.cmake. These contain the modules that need to be
|
||||||
# find_package'd when testing.
|
# find_package'd when testing.
|
||||||
|
Loading…
Reference in New Issue
Block a user