summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2023-08-18 17:33:21 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2023-08-23 16:21:58 +0200
commit2ab80a2c18f23dd8b26fbf9880500cd9abc36f6b (patch)
tree689590954c0b1494cbf486c178ee273cbe85deae /cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
parentb6849849392cf14ead014833976d1926504985d2 (diff)
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 ffe088941378e32ea30c142cca7e63c537a41ff1 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>
Diffstat (limited to 'cmake/QtBuildInternals/QtBuildInternalsConfig.cmake')
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake4
1 files changed, 4 insertions, 0 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index ceb070ec0c..913e0cbcff 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -717,6 +717,10 @@ endfunction()
macro(qt_build_tests)
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)
# Find location of TestsConfig.cmake. These contain the modules that need to be
# find_package'd when testing.