diff options
| author | Alexandru Croitor <[email protected]> | 2025-11-24 18:03:52 +0100 |
|---|---|---|
| committer | Alexandru Croitor <[email protected]> | 2025-11-26 16:51:46 +0100 |
| commit | b8579cad356860cc3ae0e9b74ba483c2049807f6 (patch) | |
| tree | 4a1ebae81813a234f8301fb02789fcde20444ace | |
| parent | 1ecb20a868a2101189e3223150e01bf1b9f215b1 (diff) | |
CMake: Look for packages in Standalone Tests Config files individually
So that cmake has the opportunity to show a warning for each missing
component, not just the first one.
Amends dd1030a4501ca067e96f50085c8cfda19d85afd4
Pick-to: 6.8 6.10
Change-Id: I850d5c216437486aa5eb83543ac9a2e024b4be9f
Reviewed-by: Alexey Edelev <[email protected]>
| -rw-r--r-- | cmake/QtBuildRepoHelpers.cmake | 35 | ||||
| -rw-r--r-- | cmake/QtPostProcessHelpers.cmake | 11 | ||||
| -rw-r--r-- | cmake/QtStandaloneTestsConfig.cmake.in | 10 |
3 files changed, 44 insertions, 12 deletions
diff --git a/cmake/QtBuildRepoHelpers.cmake b/cmake/QtBuildRepoHelpers.cmake index 1429448c2f8..5961424c38b 100644 --- a/cmake/QtBuildRepoHelpers.cmake +++ b/cmake/QtBuildRepoHelpers.cmake @@ -724,6 +724,41 @@ macro(qt_internal_find_standalone_test_config_file) endif() endmacro() +# Used inside the standalone parts config file to find all requested Qt module packages. +# standalone_parts_args_var_name should be the var name in the outer scope that contains +# all the arguments for this function. +macro(qt_internal_find_standalone_parts_qt_packages standalone_parts_args_var_name) + set(__standalone_parts_opt_args "") + set(__standalone_parts_single_args "") + set(__standalone_parts_multi_args + QT_MODULE_PACKAGES + ) + cmake_parse_arguments(__standalone_parts + "${__standalone_parts_opt_args}" + "${__standalone_parts_single_args}" + "${__standalone_parts_multi_args}" + ${${standalone_parts_args_var_name}}) + + # Packages looked up in standalone tests Config files should use the same version as + # the one recorded on the Platform target. + qt_internal_get_package_version_of_target(Platform __standalone_parts_main_qt_package_version) + + if(__standalone_parts_QT_MODULE_PACKAGES) + foreach(__standalone_parts_package_name IN LISTS __standalone_parts_QT_MODULE_PACKAGES) + find_package(${QT_CMAKE_EXPORT_NAMESPACE} + "${__standalone_parts_main_qt_package_version}" + COMPONENTS "${__standalone_parts_package_name}") + endforeach() + endif() + + unset(__standalone_parts_opt_args) + unset(__standalone_parts_single_args) + unset(__standalone_parts_multi_args) + unset(__standalone_parts_QT_MODULE_PACKAGES) + unset(__standalone_parts_main_qt_package_version) + unset(__standalone_parts_package_name) +endmacro() + # Used by standalone tests and standalone non-ExternalProject examples to find all installed qt # packages. macro(qt_internal_find_standalone_parts_config_files) diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake index 12f5c617960..b8e46085a98 100644 --- a/cmake/QtPostProcessHelpers.cmake +++ b/cmake/QtPostProcessHelpers.cmake @@ -819,7 +819,7 @@ function(qt_internal_create_config_file_for_standalone_tests) # standalone tests, and it can happen that Core or Gui features are not # imported early enough, which means FindWrapPNG will try to find a system PNG library instead # of the bundled one. - set(modules) + set(modules "") foreach(m ${QT_REPO_KNOWN_MODULES}) get_target_property(target_type "${m}" TYPE) @@ -835,12 +835,9 @@ function(qt_internal_create_config_file_for_standalone_tests) endif() endforeach() - list(JOIN modules " " QT_REPO_KNOWN_MODULES_STRING) - string(STRIP "${QT_REPO_KNOWN_MODULES_STRING}" QT_REPO_KNOWN_MODULES_STRING) - # Skip generating and installing file if no modules were built. This make sure not to install # anything when build qtx11extras on macOS for example. - if(NOT QT_REPO_KNOWN_MODULES_STRING) + if(NOT modules) return() endif() @@ -848,8 +845,8 @@ function(qt_internal_create_config_file_for_standalone_tests) # of the current repo. This is used for standalone tests. qt_internal_get_standalone_parts_config_file_name(tests_config_file_name) - # Standalone tests Config files should follow the main versioning scheme. - qt_internal_get_package_version_of_target(Platform main_qt_package_version) + # Substitution variables. + list(JOIN modules "\n " QT_MODULE_PACKAGES) configure_file( "${QT_CMAKE_DIR}/QtStandaloneTestsConfig.cmake.in" diff --git a/cmake/QtStandaloneTestsConfig.cmake.in b/cmake/QtStandaloneTestsConfig.cmake.in index 39200167a58..9d548d14699 100644 --- a/cmake/QtStandaloneTestsConfig.cmake.in +++ b/cmake/QtStandaloneTestsConfig.cmake.in @@ -1,8 +1,8 @@ # Copyright (C) 2024 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -# TODO: Ideally this should look for each Qt module separately, with each module's specific version, -# bypassing the Qt6 Config file, aka find_package(Qt6SpecificFoo) repated x times. But it's not -# critical. -find_package(@INSTALL_CMAKE_NAMESPACE@ @main_qt_package_version@ - COMPONENTS @QT_REPO_KNOWN_MODULES_STRING@) +set(__standalone_parts_qt_packages_args + QT_MODULE_PACKAGES + @QT_MODULE_PACKAGES@ +) +qt_internal_find_standalone_parts_qt_packages(__standalone_parts_qt_packages_args) |
