diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-10-30 11:27:36 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-11-12 18:06:36 +0100 |
commit | 8cdbcee614dbb34d4ac770bee1734c18ea27fa12 (patch) | |
tree | e992b2070de283c558df9e261580365d5ccf4937 /src/qml/Qt6QmlPluginTemplate.cpp.in | |
parent | ccb9c17d29cb680dd01318f5e59e7edab26b73c6 (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/Qt6QmlPluginTemplate.cpp.in')
-rw-r--r-- | src/qml/Qt6QmlPluginTemplate.cpp.in | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/qml/Qt6QmlPluginTemplate.cpp.in b/src/qml/Qt6QmlPluginTemplate.cpp.in new file mode 100644 index 0000000000..9788932743 --- /dev/null +++ b/src/qml/Qt6QmlPluginTemplate.cpp.in @@ -0,0 +1,23 @@ +// This file is autogenerated by CMake. +// It facilitates usage of a pure QML module as a static QML plugin. + +#include <QtQml/qqmlextensionplugin.h> + +@qt_qml_plugin_intro@ + +class @qt_qml_plugin_class_name@ : public QQmlEngineExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid) + +public: + @qt_qml_plugin_class_name@(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) + { + Q_UNUSED(parent); + @qt_qml_plugin_constructor_content@ + } +}; + +@qt_qml_plugin_outro@ + +#include "@qt_qml_plugin_moc_include_name@" |