aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickshapes
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2021-06-02 16:54:21 +1000
committerCraig Scott <craig.scott@qt.io>2021-06-04 16:54:52 +1000
commit1c4ba17015fe99da48ce73fab75ecc60cf9cb975 (patch)
tree1311d8cebc4007d43888477045ca534404f2f7ca /src/quickshapes
parent6432e00b954beec7d0c6bc9b70fed6191b87bd38 (diff)
Refactor and update qml CMake API
The existing CMake API for qml modules had a number of shortcomings. Refactor it to achieve the following: - Clearly separate public and internal aspects. - Re-use code from qtbase for adding plugins and module targets rather than reimplementing close variations. - Provide more robust and complete support for qmllint, qmlcachegen and automatic generation of qmldir files. - Reduce the steps needed for more common scenarios. - Encourage the use of separate backing library and plugin targets. - Automatically generate the plugin class .cpp file where possible. - Specify .qml files directly through qml-specific API elements rather than assuming they can be extracted out of a set of resources. [ChangeLog][QtQml] The qml CMake API has changed from 6.1 and is now out of Technical Preview status. The most notable change is that .qml files should no longer be specified as resources, there is dedicated handling for them in the qt6_add_qml_module(). A related change is that the qt6_target_qml_files() command has been replaced by qt6_target_qml_sources(). More complete integration with qmlcachegen, qmllint and qmldir generation is also part of the CMake API. Fixes: QTBUG-91621 Task-number: QTBUG-82598 Task-number: QTBUG-88763 Task-number: QTBUG-89274 Task-number: QTBUG-91444 Change-Id: I25aae1b0e89890394dfe2ba2824008164b2ca8d9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/quickshapes')
-rw-r--r--src/quickshapes/CMakeLists.txt35
-rw-r--r--src/quickshapes/qquickshapesplugin.cpp63
2 files changed, 79 insertions, 19 deletions
diff --git a/src/quickshapes/CMakeLists.txt b/src/quickshapes/CMakeLists.txt
index b8838b6a18..0f842d79ac 100644
--- a/src/quickshapes/CMakeLists.txt
+++ b/src/quickshapes/CMakeLists.txt
@@ -1,10 +1,16 @@
-# Generated from quickshapes.pro.
-
#####################################################################
## QuickShapes Module:
#####################################################################
-qt_internal_add_module(QuickShapes
+qt_internal_add_qml_module(QuickShapes
+ URI "QtQuick.Shapes"
+ VERSION "${PROJECT_VERSION}"
+ PLUGIN_TARGET qmlshapesplugin
+ NO_PLUGIN_OPTIONAL
+ NO_GENERATE_PLUGIN_SOURCE
+ CLASS_NAME QmlShapesPlugin
+ DEPENDENCIES
+ QtQuick
INTERNAL_MODULE
SOURCES
qquickshape.cpp qquickshape_p.h
@@ -19,6 +25,13 @@ qt_internal_add_module(QuickShapes
Qt::QuickPrivate
)
+# We need to do additional initialization, so we have to provide our own
+# plugin class rather than using the generated one
+qt_internal_extend_target(qmlshapesplugin
+ SOURCES qquickshapesplugin.cpp
+ LIBRARIES Qt::QuickShapesPrivate
+)
+
# Resources:
set(qtquickshapes_resource_files
"shaders_ng/conicalgradient.frag.qsb"
@@ -36,19 +49,3 @@ qt_internal_add_resource(QuickShapes "qtquickshapes"
${qtquickshapes_resource_files}
)
-
-#### Keys ignored in scope 1:.:.:quickshapes.pro:<TRUE>:
-# QMLTYPES_FILENAME = "plugins.qmltypes"
-# QMLTYPES_INSTALL_DIR = "$$[QT_INSTALL_QML]/QtQuick/Shapes"
-# QML_IMPORT_NAME = "QtQuick.Shapes"
-# QML_IMPORT_VERSION = "$$QT_VERSION"
-
-set_target_properties(QuickShapes PROPERTIES
- QT_QML_MODULE_INSTALL_QMLTYPES TRUE
- QT_QML_MODULE_VERSION ${PROJECT_VERSION}
- QT_QML_MODULE_URI QtQuick.Shapes
- QT_QMLTYPES_FILENAME plugins.qmltypes
- QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/QtQuick/Shapes"
-)
-
-qt6_qml_type_registration(QuickShapes)
diff --git a/src/quickshapes/qquickshapesplugin.cpp b/src/quickshapes/qquickshapesplugin.cpp
new file mode 100644
index 0000000000..587c546fca
--- /dev/null
+++ b/src/quickshapes/qquickshapesplugin.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QtQuickShapes/private/qquickshape_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QmlShapesPlugin : public QQmlEngineExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
+
+public:
+ QmlShapesPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_QtQuick_Shapes;
+ volatile auto initialize = &QQuickShapes_initializeModule;
+ Q_UNUSED(registration);
+ Q_UNUSED(initialize);
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "qquickshapesplugin.moc"