summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2022-03-03 12:04:48 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2022-03-08 03:45:29 +0100
commit1c2f6d2aceeb218786fde0ee0cb2ffd207d1e0b1 (patch)
tree9861350f85637412bb114407eb319c4a383944ad /util
parentf5a8d70deedb4bb2270be1f1ded9ddd3c4071d41 (diff)
pro2cmake: Write only one find_package call for Qt packages
Task-number: QTBUG-96799 Change-Id: I1eb8ac05f360b74e5ae1217b5535a33227b5084b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util')
-rw-r--r--util/cmake/helper.py4
-rwxr-xr-xutil/cmake/pro2cmake.py20
2 files changed, 21 insertions, 3 deletions
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: