path: root/tests/auto/cmake/CMakeLists.txt
diff options
authorAlexandru Croitor <>2020-07-20 17:12:45 +0200
committerAlexandru Croitor <>2020-07-20 18:12:23 +0200
commit5e0129f63cbd45767342c43135f6061750511e33 (patch)
tree18b0a9331d618988d6247dfa1843a8599dbfdbe6 /tests/auto/cmake/CMakeLists.txt
parentbd143f7df3be50b15b617275b0db2aac292b9a26 (diff)
CMake: Fix configuration of CMake tests in-build-tree
Qt6 package was not found the tests were configured in-tree as opposed to standalone tests. Use the same trick we do for building examples in-tree. Specify the path to the build tree packages, and don't create targets. Amends 96e3ee06598d00e7155f3f8574759ea658a134e5 Change-Id: Ia60de416ce0afff5bd40be8c0c6e3c7898fd7ebf Reviewed-by: Cristian Adam <>
Diffstat (limited to 'tests/auto/cmake/CMakeLists.txt')
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index b270ab4eda..1ad56e1adc 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -60,6 +60,11 @@ set(required_packages Core Network Xml Sql Test)
set(optional_packages DBus Gui Widgets PrintSupport OpenGL Concurrent)
# Setup the test when called as a completely standalone project.
+if(TARGET Qt6::Core)
+ # Tests are built as part of the qtbase build tree.
+ # Setup paths so that the Qt packages are found, similar to examples.
+ qt_internal_set_up_build_dir_package_paths()
find_package(Qt6 REQUIRED COMPONENTS ${required_packages})
find_package(Qt6 OPTIONAL_COMPONENTS ${optional_packages})