From 6e2ca1d6cb12d37a00d0c61b1aac317df02ac786 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Tue, 24 Sep 2019 11:39:26 +0200 Subject: [PATCH] Add SKIP_TYPE_REGISTRATION option to add_qml_module If the qml files are not listed in the qmldir file they do not need to be written again, since it is expected that they are registered by the c++ plugin code. Change-Id: I624aedb182583f942bf1d1a322861c47a64b5065 Reviewed-by: Alexandru Croitor Reviewed-by: Qt CMake Build Bot --- cmake/QtBuild.cmake | 8 ++++++++ util/cmake/pro2cmake.py | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 8f249a15fec..409907bf58a 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -2049,12 +2049,15 @@ endfunction() # VERSION: Version of the qml module # QML_PLUGINDUMP_DEPENDENCIES: Path to a dependencies.json file to be consumed # with the ${target}_qmltypes target (optional) +# SKIP_TYPE_REGISTRATION: All qml files are expected to be registered by the +# c++ plugin code. # function(add_qml_module target) set(qml_module_optional_args DESIGNER_SUPPORTED DO_NOT_INSTALL + SKIP_TYPE_REGISTRATION ) set(qml_module_single_args @@ -2130,9 +2133,14 @@ function(add_qml_module target) set(designer_supported_arg DESIGNER_SUPPORTED) endif() + if (arg_SKIP_TYPE_REGISTRATION) + set(skip_registration_arg SKIP_TYPE_REGISTRATION) + endif() + qt6_add_qml_module(${target} ${designer_supported_arg} ${no_create_option} + ${skip_registration_arg} ${classname_arg} RESOURCE_PREFIX "/qt-project.org/imports" TARGET_PATH ${arg_TARGET_PATH} diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index a2bbce53f0e..4a88bf95b8e 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -2905,6 +2905,8 @@ def write_example( add_target += " DEPENDENCIES\n" for dep in qml_dir.depends: add_target += f" {dep[0]}/{dep[1]}\n" + if len(qml_dir.type_names) == 0: + add_target += " SKIP_TYPE_REGISTRATION\n" add_target += " INSTALL_LOCATION ${INSTALL_EXAMPLEDIR}\n)\n\n" add_target += f"target_sources({binary_name} PRIVATE" @@ -3056,6 +3058,8 @@ def write_qml_plugin( extra_lines.append("DEPENDENCIES") for dep in qml_dir.depends: extra_lines.append(f" {dep[0]}/{dep[1]}") + if len(qml_dir.type_names) == 0: + extra_lines.append("SKIP_TYPE_REGISTRATION") return qml_dir