From 89ad6f964c90d6610aadb688a5645e5d6e428b08 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor <alexandru.croitor@qt.io> Date: Thu, 23 Jan 2025 11:51:11 +0100 Subject: [PATCH] Ensure all known Qt packages are looked up So that we generate a full list of qml modules to link in. --- src/CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8d1eec2..6e0b720 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,6 +6,25 @@ find_package( find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network WebSockets) +# In shared Qt builds, the qml plugins don't have dependencies on their backing libraries, and +# thus the backing library packages are not automatically looked up. +# The StandaloneTests directory contains Config files that find_package all installed Qt packages. +# Abuse that, and include all of them to make all the backing libraries available as imported +# targets. +find_package(Qt6 COMPONENTS BuildInternals) +if(Qt6BuildInternals_DIR) + set(standalone_tests_dir "${Qt6BuildInternals_DIR}/StandaloneTests") + if(EXISTS "${standalone_tests_dir}") + # Glob the config files in there. + file(GLOB_RECURSE standalone_tests_files "${standalone_tests_dir}/*TestsConfig.cmake") + + # Include each one of them. + foreach(standalone_tests_file IN LISTS standalone_tests_files) + include("${standalone_tests_file}") + endforeach() + endif() +endif() + set(imports "") # Get all imported targets. -- GitLab