CMake: Allow using existing backing target for a new qml module

qtwayland has a case where the backing target is always created by
qt_internal_add_module and it is promoted to a qml module
conditionally only if Qt::Qml target exists.

qt_internal_add_qml_module always tries to create a backing target.

Allow passing an internal only NO_CREATE_BACKING_TARGET option to
re-use an existing target, while still applying necessary qml-specific
install rules.

Amends 1c4ba17015

Task-number: QTBUG-91621
Change-Id: I15f4da4fd3a3ab991c78e8c77975677a0d820fd5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Alexandru Croitor 2021-06-04 11:40:23 +02:00
parent 3f4088256c
commit cb293ee3af
1 changed files with 34 additions and 19 deletions

View File

@ -74,17 +74,29 @@ function(qt_internal_add_qml_module target)
# Args used by qt_internal_add_qml_module directly, which should not be passed to any other
# functions.
#
# NO_CREATE_BACKING_TARGET option skips the creation of the backing target. It is useful in
# the case where the backing target already exists, a plugin target should still be created
# and the qml specific install rules should still apply to the backing target.
#
# INSTALL_SOURCE_QMLTYPES takes a path to an existing plugins.qmltypes file that should be
# installed.
#
# INSTALL_SOURCE_QMLDIR takes a path to an existing qmldir file that should be installed.
set(internal_option_args
NO_CREATE_BACKING_TARGET
)
set(internal_single_args
INSTALL_SOURCE_QMLTYPES
INSTALL_SOURCE_QMLDIR)
INSTALL_SOURCE_QMLDIR
)
set(option_args
${module_option_args}
${qml_module_option_args}
${ignore_option_args}
${internal_option_args}
)
set(single_args
${module_single_args}
@ -130,6 +142,7 @@ function(qt_internal_add_qml_module target)
set(plugin_args "")
if(NOT arg_PLUGIN_TARGET STREQUAL target)
if(NOT arg_NO_CREATE_BACKING_TARGET)
# Create the backing target now to handle module-related things
qt_remove_args(module_args
ARGS_TO_REMOVE
@ -137,6 +150,7 @@ function(qt_internal_add_qml_module target)
${qml_module_option_args}
${qml_module_single_args}
${qml_module_multi_args}
${internal_option_args}
${internal_single_args}
OUTPUT_DIRECTORY
INSTALL_DIRECTORY
@ -148,6 +162,7 @@ function(qt_internal_add_qml_module target)
${ARGN}
)
qt_internal_add_module(${target} ${module_args})
endif()
else()
# Since we are not creating a separate backing target, we have to pass
# through the default args to the plugin target creation instead