diff --git a/util/cmake/helper.py b/util/cmake/helper.py index 900975de36..0a363eb4d3 100644 --- a/util/cmake/helper.py +++ b/util/cmake/helper.py @@ -786,6 +786,7 @@ def generate_find_package_info( indent: int = 0, emit_if: str = "", use_system_package_name: bool = False, + remove_REQUIRED_from_extra: bool = True, module: str = "", ) -> str: isRequired = False @@ -797,7 +798,8 @@ def generate_find_package_info( if "REQUIRED" in extra and use_qt_find_package: isRequired = True - extra.remove("REQUIRED") + if remove_REQUIRED_from_extra: + extra.remove("REQUIRED") cmake_target_name = lib.targetName assert cmake_target_name diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 93e6e6efa6..46aa3dc6f6 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -3741,9 +3741,25 @@ def write_find_package_section( if info and info not in packages: packages.append(info) - # ind = spaces(indent) + qt_components: List[str] = [] + for p in filter(LibraryMapping.is_qt, packages): + if p.components is not None: + qt_components += p.components + if qt_components: + qt_components = sorted(qt_components) + qt_package = LibraryMapping( + "unknown", "Qt6", "unknown", extra=["REQUIRED"], components=qt_components + ) + cm_fh.write( + generate_find_package_info( + qt_package, + use_qt_find_package=False, + remove_REQUIRED_from_extra=False, + indent=indent, + ) + ) - for p in packages: + for p in itertools.filterfalse(LibraryMapping.is_qt, packages): cm_fh.write(generate_find_package_info(p, use_qt_find_package=False, indent=indent)) if packages: