summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-12-04 11:09:33 +0100
committerLeander Beernaert <leander.beernaert@qt.io>2020-01-24 12:29:30 +0000
commitcce8ada8141d786c1deda78fdba485b4c67f9687 (patch)
treee5366b6b43480f11c03c00b75b95f04b2faf1644 /util
parent48c82e90af12da74c713665ddfd7f8d825ae5bdb (diff)
Support for QML Type Registrar
Change-Id: Ifc1f44cf40b22c20ab768333ba9d5ce58a5f7250 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-xutil/cmake/pro2cmake.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 3ad427f609..fe2a08b71f 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -2839,7 +2839,7 @@ def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
extra.append("NO_PRIVATE_MODULE")
if "header_module" in scope.get("CONFIG"):
extra.append("HEADER_MODULE")
- if "metatypes" in scope.get("CONFIG"):
+ if "metatypes" in scope.get("CONFIG") or "qmltypes" in scope.get("CONFIG"):
extra.append("GENERATE_METATYPES")
module_config = scope.get("MODULE_CONFIG")
@@ -3280,6 +3280,8 @@ def write_plugin(cm_fh, scope, *, indent: int = 0) -> str:
extra.append(f'INSTALL_DIRECTORY "{target_path}"')
else:
extra.append("SKIP_INSTALL")
+ if "qmltypes" in scope.get("CONFIG"):
+ extra.append("GENERATE_QMLTYPES")
plugin_class_name = scope.get_string("PLUGIN_CLASS_NAME")
if plugin_class_name:
@@ -3498,6 +3500,39 @@ def handle_app_or_lib(
footer=")\n",
)
+ # Generate qmltypes instruction for anything that may have CONFIG += qmltypes
+ # that is not a qml plugin
+ if "qmltypes" in scope.get("CONFIG") and not "qml_plugin" in scope.get("_LOADED"):
+ cm_fh.write(f"\n{spaces(indent)}set_target_properties({target} PROPERTIES\n")
+ cm_fh.write(f"{spaces(indent+1)}QT_QML_MODULE_INSTALL_QMLTYPES TRUE\n")
+
+ import_version = scope.get_string("IMPORT_VERSION")
+ if not import_version:
+ import_version = scope.get_string("QML_IMPORT_VERSION")
+ if import_version:
+ import_version = import_version.replace(
+ "$$QT_MINOR_VERSION", "${CMAKE_PROJECT_VERSION_MINOR}"
+ )
+ cm_fh.write(f"{spaces(indent+1)}QT_QML_MODULE_VERSION {import_version}\n")
+
+ import_name = scope.expandString("QML_IMPORT_NAME")
+ if import_name:
+ cm_fh.write(f"{spaces(indent+1)}QT_QML_MODULE_URI {import_name}\n")
+
+ target_path = scope.get("TARGETPATH")
+ if target_path:
+ cm_fh.write(f"{spaces(indent+1)}QT_QML_MODULE_TARGET_PATH {target_path}\n")
+
+ install_dir = scope.expandString("QMLTYPES_INSTALL_DIR")
+ if install_dir:
+ install_dir = install_dir.replace(
+ "$$[QT_INSTALL_QML]","${Qt6_DIR}/../../../qml"
+ )
+ cm_fh.write(f"{spaces(indent+1)}QT_QML_MODULE_INSTALL_DIR \"{install_dir}\"\n")
+
+ cm_fh.write(f"{spaces(indent)})\n\n")
+ cm_fh.write(f"qt6_qml_type_registration({target})\n")
+
def handle_top_level_repo_project(scope: Scope, cm_fh: IO[str]):
# qtdeclarative