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 <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
This commit is contained in:
Leander Beernaert 2019-09-24 11:39:26 +02:00
parent d64fa78829
commit 6e2ca1d6cb
2 changed files with 12 additions and 0 deletions

View File

@ -2049,12 +2049,15 @@ endfunction()
# VERSION: Version of the qml module # VERSION: Version of the qml module
# QML_PLUGINDUMP_DEPENDENCIES: Path to a dependencies.json file to be consumed # QML_PLUGINDUMP_DEPENDENCIES: Path to a dependencies.json file to be consumed
# with the ${target}_qmltypes target (optional) # 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) function(add_qml_module target)
set(qml_module_optional_args set(qml_module_optional_args
DESIGNER_SUPPORTED DESIGNER_SUPPORTED
DO_NOT_INSTALL DO_NOT_INSTALL
SKIP_TYPE_REGISTRATION
) )
set(qml_module_single_args set(qml_module_single_args
@ -2130,9 +2133,14 @@ function(add_qml_module target)
set(designer_supported_arg DESIGNER_SUPPORTED) set(designer_supported_arg DESIGNER_SUPPORTED)
endif() endif()
if (arg_SKIP_TYPE_REGISTRATION)
set(skip_registration_arg SKIP_TYPE_REGISTRATION)
endif()
qt6_add_qml_module(${target} qt6_add_qml_module(${target}
${designer_supported_arg} ${designer_supported_arg}
${no_create_option} ${no_create_option}
${skip_registration_arg}
${classname_arg} ${classname_arg}
RESOURCE_PREFIX "/qt-project.org/imports" RESOURCE_PREFIX "/qt-project.org/imports"
TARGET_PATH ${arg_TARGET_PATH} TARGET_PATH ${arg_TARGET_PATH}

View File

@ -2905,6 +2905,8 @@ def write_example(
add_target += " DEPENDENCIES\n" add_target += " DEPENDENCIES\n"
for dep in qml_dir.depends: for dep in qml_dir.depends:
add_target += f" {dep[0]}/{dep[1]}\n" 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 += " INSTALL_LOCATION ${INSTALL_EXAMPLEDIR}\n)\n\n"
add_target += f"target_sources({binary_name} PRIVATE" add_target += f"target_sources({binary_name} PRIVATE"
@ -3056,6 +3058,8 @@ def write_qml_plugin(
extra_lines.append("DEPENDENCIES") extra_lines.append("DEPENDENCIES")
for dep in qml_dir.depends: for dep in qml_dir.depends:
extra_lines.append(f" {dep[0]}/{dep[1]}") extra_lines.append(f" {dep[0]}/{dep[1]}")
if len(qml_dir.type_names) == 0:
extra_lines.append("SKIP_TYPE_REGISTRATION")
return qml_dir return qml_dir