summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xutil/cmake/configurejson2cmake.py28
-rw-r--r--util/cmake/helper.py39
2 files changed, 42 insertions, 25 deletions
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py
index 8b9251f8a7..040e8ee7b4 100755
--- a/util/cmake/configurejson2cmake.py
+++ b/util/cmake/configurejson2cmake.py
@@ -33,7 +33,8 @@ import re
import sys
from typing import Set, Union, List, Dict
-from helper import map_qt_library, featureName, map_platform, find_3rd_party_library_mapping
+from helper import map_qt_library, featureName, map_platform, \
+ find_3rd_party_library_mapping, generate_find_package_info
knownTests = set() # type: Set[str]
@@ -182,31 +183,8 @@ def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set):
cmake_find_packages_set.add(newlib.targetName)
- isRequired = False
+ cm_fh.write(generate_find_package_info(newlib))
- extra = newlib.extra.copy()
-
- if extra:
- if "REQUIRED" in extra:
- isRequired = True
- extra.remove("REQUIRED")
-
- cmake_target_name = newlib.targetName
-
- # _nolink or not does not matter at this point:
- if cmake_target_name.endswith('_nolink') or cmake_target_name.endswith('/nolink'):
- cmake_target_name = cmake_target_name[:-7]
-
- if cmake_target_name:
- extra += ['PROVIDED_TARGETS', cmake_target_name]
-
- if extra:
- cm_fh.write('qt_find_package({} {})\n'.format(newlib.packageName, ' '.join(extra)))
- else:
- cm_fh.write('qt_find_package({})\n'.format(newlib.packageName))
-
- if isRequired:
- cm_fh.write('set_package_properties({} PROPERTIES TYPE REQUIRED)\n'.format(newlib.packageName))
def lineify(label, value, quote=True):
if value:
diff --git a/util/cmake/helper.py b/util/cmake/helper.py
index 0aac634984..17e25ca0b0 100644
--- a/util/cmake/helper.py
+++ b/util/cmake/helper.py
@@ -338,3 +338,42 @@ def map_3rd_party_library(lib: str) -> str:
if not mapping or not mapping.targetName:
return lib
return mapping.targetName + libpostfix
+
+
+def generate_find_package_info(lib: LibraryMapping, use_qt_find_package: bool=True, *,
+ indent: int = 0) -> str:
+ isRequired = False
+
+ extra = lib.extra.copy()
+
+ if "REQUIRED" in extra and use_qt_find_package:
+ isRequired = True
+ extra.remove("REQUIRED")
+
+ cmake_target_name = lib.targetName
+
+ # _nolink or not does not matter at this point:
+ if cmake_target_name.endswith('_nolink') or cmake_target_name.endswith('/nolink'):
+ cmake_target_name = cmake_target_name[:-7]
+
+ if cmake_target_name and use_qt_find_package:
+ extra += ['PROVIDED_TARGETS', cmake_target_name]
+
+ result = ''
+ ind = ' ' * indent
+
+ if use_qt_find_package:
+ if extra:
+ result = '{}qt_find_package({} {})\n'.format(ind, lib.packageName, ' '.join(extra))
+ else:
+ result = '{}qt_find_package({})\n'.format(ind, lib.packageName)
+
+ if isRequired:
+ result += '{}set_package_properties({} PROPERTIES TYPE REQUIRED)\n'.format(ind, lib.packageName)
+ else:
+ if extra:
+ result = '{}find_package({} {})\n'.format(ind, lib.packageName, ' '.join(extra))
+ else:
+ result = '{}find_package({})\n'.format(ind, lib.packageName)
+
+ return result