aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/Qt6QmlBuildInternals.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-10-30 11:27:36 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-11-12 18:06:36 +0100
commit8cdbcee614dbb34d4ac770bee1734c18ea27fa12 (patch)
treee992b2070de283c558df9e261580365d5ccf4937 /src/qml/Qt6QmlBuildInternals.cmake
parentccb9c17d29cb680dd01318f5e59e7edab26b73c6 (diff)
CMake: Allow building pure QML modules not backed by C++ sources
When no C++ sources are passed to qt_internal_add_qml_plugin (a pure QML module), create a C++ backed Qt plugin anyway. In such a case, generate a dummy plugin.cpp containing a QQmlEngineExtensionPlugin subclass. The class name is autogenerated from the QML import URI. The class constructor will call the qmltyperegistrar generated void qml_register_types_foo() function, to ensure the needed module versions are registered for the QML module. Change-Id: I19959dafdf0dc837c6037e7dc1d549b7420110a7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/Qt6QmlBuildInternals.cmake')
-rw-r--r--src/qml/Qt6QmlBuildInternals.cmake34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/qml/Qt6QmlBuildInternals.cmake b/src/qml/Qt6QmlBuildInternals.cmake
index d25c987fc9..f6f1c98ecb 100644
--- a/src/qml/Qt6QmlBuildInternals.cmake
+++ b/src/qml/Qt6QmlBuildInternals.cmake
@@ -9,7 +9,6 @@ include_guard(GLOBAL)
# in an IDE. Finally, it will also create a custom ${target}_qmltypes which
# can be used to generate the respective plugins.qmltypes file.
#
-# CPP_PLUGIN: Whether this qml module has any c++ source files.
# URI: Module's uri.
# TARGET_PATH: Expected installation path for the Qml Module. Equivalent
# to the module's URI where '.' is replaced with '/'. Use this to override the
@@ -79,22 +78,15 @@ function(qt_internal_add_qml_module target)
${ARGV}
)
- # If we have no sources, but qml files, create a custom target so the
- # qml file will be visibile in an IDE.
- if (arg_SOURCES)
- qt_internal_add_plugin(${target}
- TYPE
- qml_plugin
- QML_TARGET_PATH
- "${arg_TARGET_PATH}"
- ${plugin_args}
- )
- endif()
-
+ qt_internal_add_plugin(${target}
+ TYPE
+ qml_plugin
+ QML_TARGET_PATH
+ "${arg_TARGET_PATH}"
+ ${plugin_args}
+ )
- if (arg_CPP_PLUGIN OR arg_SOURCES)
- set(no_create_option DO_NOT_CREATE_TARGET)
- endif()
+ set(no_create_option DO_NOT_CREATE_TARGET)
if (arg_CLASSNAME)
set(classname_arg CLASSNAME ${arg_CLASSNAME})
@@ -120,6 +112,15 @@ function(qt_internal_add_qml_module target)
set(install_qmltypes_arg INSTALL_QMLTYPES)
endif()
+
+ # Because qt_internal_add_qml_module does not propagate its SOURCES option to
+ # qt6_add_qml_module, but only to qt_internal_add_plugin, we need a way to tell
+ # qt6_add_qml_module if it should generate a dummy plugin cpp file. Otherwise we'd generate
+ # a dummy plugin.cpp file twice and thus cause duplicate symbol issues.
+ if (NOT arg_SOURCES)
+ set(pure_qml_module "PURE_MODULE")
+ endif()
+
qt_path_join(qml_module_install_dir ${QT_INSTALL_DIR} "${INSTALL_QMLDIR}/${arg_TARGET_PATH}")
set(qml_module_build_dir "")
@@ -140,6 +141,7 @@ function(qt_internal_add_qml_module target)
${classname_arg}
${generate_qmltypes_arg}
${install_qmltypes_arg}
+ ${pure_qml_module}
RESOURCE_PREFIX "/qt-project.org/imports"
TARGET_PATH ${arg_TARGET_PATH}
URI ${arg_URI}