kde/kf6-extra-cmake-modules: rebase to 6.28.0 (ECM) + teach version parser set(VERSION)
kf6-kcoreaddons 6.28.0 requires ECM >= 6.28.0 but the vendored ECM source/ was still 6.10.0: the sync engine skipped it because ECM's version marker is a bare set(VERSION "X.Y.Z") that the parser didn't recognize (only KF_VERSION / PROJECT_VERSION / RELEASE_SERVICE_VERSION). Re-lay ECM from its 6.28.0 source.tar (pure cmake modules, no Redox port) and teach both the sync engine and the validator to read set(VERSION) so this class is caught, not silently skipped.
This commit is contained in:
@@ -7,32 +7,75 @@
|
||||
ECMQmlModule
|
||||
------------
|
||||
|
||||
This file contains helper functions to make it easier to create QML modules. It
|
||||
takes care of a number of things that often need to be repeated. It also takes
|
||||
care of special handling of QML modules between shared and static builds. When
|
||||
building a static version of a QML module, the relevant QML source files are
|
||||
bundled into the static library. When using a shared build, the QML plugin and
|
||||
relevant QML files are copied to the target's ``RUNTIME_OUTPUT_DIRECTORY`` to make
|
||||
it easier to run things directly from the build directory.
|
||||
Helper functions to make it easier to create QML modules.
|
||||
|
||||
This CMake module lets you create QML-enabled targets, add C++ and QML files
|
||||
to them, and finalize the module if needed. When using Qt 6, it allows for
|
||||
`declarative registration of QML types <https://www.qt.io/blog/qml-type-registration-in-qt-5.15>`_.
|
||||
|
||||
This CMake module reduces boilerplate and takes care of special
|
||||
handling of QML modules between shared and static builds:
|
||||
|
||||
- When building a static version of a QML module, the relevant QML source
|
||||
files are bundled into the static library.
|
||||
|
||||
- When using a shared build, the QML plugin and relevant QML files are copied
|
||||
to the target's ``RUNTIME_OUTPUT_DIRECTORY`` to make it easier to run things
|
||||
directly from the build directory.
|
||||
|
||||
Since 6.0.0, when using Qt 6, most functionality of this module has been
|
||||
implemented by upstream Qt. Most of the functions here will now forward to the
|
||||
similar Qt functions.
|
||||
|
||||
Example usage:
|
||||
Example usage with an executable as backing target:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
ecm_add_qml_module(ExampleModule URI "org.example.Example")
|
||||
add_executable(app)
|
||||
ecm_add_qml_module(app
|
||||
URI "org.example.Example"
|
||||
)
|
||||
|
||||
target_sources(ExampleModule PRIVATE ExamplePlugin.cpp)
|
||||
target_link_libraries(ExampleModule PRIVATE Qt::Quick)
|
||||
target_sources(app PRIVATE main.cpp)
|
||||
target_link_libraries(app PRIVATE Qt::Quick)
|
||||
|
||||
ecm_target_qml_sources(ExampleModule SOURCES ExampleItem.qml) # This will have 1.0 as the default version
|
||||
ecm_target_qml_sources(ExampleModule SOURCES AnotherExampleItem.qml VERSION 1.5)
|
||||
ecm_target_qml_sources(app SOURCES ExampleItem.qml) # This will have 1.0 as the default version
|
||||
ecm_target_qml_sources(app SOURCES AnotherExampleItem.qml VERSION 1.5)
|
||||
|
||||
ecm_finalize_qml_module(ExampleModule DESTINATION ${KDE_INSTALL_QMLDIR})
|
||||
install(TARGETS app ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
The above example creates an executable target, modifies the target to allow it
|
||||
to accept QML files and properties, adds source files to it, and installs it.
|
||||
|
||||
The executable is the backing target for the QML module, which in practical
|
||||
terms means the QML module is "embedded" into the executable, always being
|
||||
loaded as part of the application, and no plugin library is created.
|
||||
|
||||
Example usage with a separate QML module:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
add_library(ExampleModule)
|
||||
ecm_add_qml_module(ExampleModule
|
||||
URI org.example.Example
|
||||
GENERATE_PLUGIN_SOURCE
|
||||
)
|
||||
|
||||
target_sources(ExampleModule PRIVATE ExamplePlugin.cpp)
|
||||
target_link_libraries(ExampleModule PRIVATE Qt::Quick)
|
||||
|
||||
ecm_target_qml_sources(ExampleModule SOURCES ExampleItem.qml)
|
||||
|
||||
ecm_finalize_qml_module(ExampleModule DESTINATION ${KDE_INSTALL_QMLDIR})
|
||||
|
||||
install(TARGETS ExampleModule ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
The above example creates a library target, modifies the target to allow it to accept QML files and
|
||||
properties, adds source files to it, and finalizes the target.
|
||||
|
||||
The library acts as a plugin that is expected to be linked to an
|
||||
executable later on, in which case ``GENERATE_PLUGIN_SOURCE`` and
|
||||
``ecm_finalize_qml_module()`` are both required.
|
||||
|
||||
::
|
||||
|
||||
@@ -43,6 +86,8 @@ Example usage:
|
||||
[CLASSNAME <class name>] # Deprecated since 6.0.0 when using Qt 6, use CLASS_NAME instead
|
||||
[QT_NO_PLUGIN] # Since 6.0.0, when using Qt 6
|
||||
[GENERATE_PLUGIN_SOURCE] # Since 6.0.0, when using Qt 6
|
||||
[DEPENDENCIES <dependency> ...] # Since 6.0.0, when using Qt 6, inherited from qt_add_qml_module()
|
||||
[IMPORTS <import> ...] # Since 6.0.0, when using Qt 6, inherited from qt_add_qml_module()
|
||||
)
|
||||
|
||||
This will declare a new CMake target called ``<target name>``. The ``URI``
|
||||
@@ -54,8 +99,9 @@ version that is used by ``ecm_target_qml_sources`` when adding QML files. If it
|
||||
is not specified, a default of 1.0 is used. Additionally, if a version greater
|
||||
than or equal to 2.0 is specified, the major version is appended to the
|
||||
Qt5 installation path of the module.
|
||||
In case you don't specify and version, but specify a version for the individual sources, the latest
|
||||
will be set as the resulting version for this plugin. This will be used in the ECMFindQmlModule module.
|
||||
In case you don't specify a version for the module, but specify a version for
|
||||
the individual sources, the latter will be set as the resulting version for
|
||||
this module. This will also be used in the ECMFindQmlModule module.
|
||||
|
||||
If the option ``NO_PLUGIN`` is set, a target is declared that is not expected to
|
||||
contain any C++ QML plugin.
|
||||
@@ -73,14 +119,28 @@ Since 6.0.0, when used with Qt 6, this will forward to ``qt_add_qml_module``. An
|
||||
be forwarded as well. The ``NO_PLUGIN`` argument is deprecated and implies ``GENERATE_PLUGIN_SOURCE``,
|
||||
since modules in Qt 6 always require a plugin or backing target. If you want to use Qt's behaviour for
|
||||
``NO_PLUGIN``, use ``QT_NO_PLUGIN`` instead. Additionally, to maintain backward compatibility, by
|
||||
default we pass ``NO_GENERATE_PLUGIN_SOURCE`` to ``qt_add_qml_module``. To have Qt generate the plugin
|
||||
sources, pass ``GENERATE_PLUGIN_SOURCE``.
|
||||
default we pass ``NO_GENERATE_PLUGIN_SOURCE`` to ``qt_add_qml_module``.
|
||||
|
||||
If you are using the executable as backing target for your QML module, the
|
||||
default behavior should suffice. If you are using a separate QML module,
|
||||
you will need to have Qt generate the plugin sources, in which case you
|
||||
should pass ``GENERATE_PLUGIN_SOURCE``.
|
||||
|
||||
The ``DEPENDENCIES`` and ``IMPORTS`` options come from ``qt_add_qml_module()``
|
||||
since Qt 6, and behave as in upstream Qt.
|
||||
|
||||
Use ``DEPENDENCIES`` for things like "QtCore", "QtQuick", "your.custom.qmlmodule",
|
||||
as well as C++ only dependencies. This is required for QML-exposed C++ code, like when subclassing a type or using it as a parameter type in properties and invokables.
|
||||
|
||||
Use ``IMPORTS`` to make a type available a part of a module's public interface. In other words, if a QML file imports this module, it also imports all the modules listed under IMPORTS.
|
||||
|
||||
See `Declaring module dependencies <https://doc.qt.io/qt-6/qt-add-qml-module.html#declaring-module-dependencies>`_ and `10 Tips to Make Your QML Code Faster and More Maintainable <https://www.kdab.com/10-tips-to-make-your-qml-code-faster-and-more-maintainable/>`_ for details.
|
||||
|
||||
::
|
||||
|
||||
ecm_add_qml_module_dependencies(<target> DEPENDS <module string> [<module string> ...])
|
||||
|
||||
Add the list of dependencies specified by the ``DEPENDS`` argument to be listed
|
||||
Adds the list of dependencies specified by the ``DEPENDS`` argument to be listed
|
||||
as dependencies in the generated QMLDIR file of ``<target>``.
|
||||
|
||||
Since 5.91.0
|
||||
@@ -92,7 +152,7 @@ Since 6.0.0, this is deprecated and ignored when using Qt 6, instead use the
|
||||
|
||||
ecm_target_qml_sources(<target> SOURCES <source.qml> [<source.qml> ...] [VERSION <version>] [PATH <path>] [PRIVATE])
|
||||
|
||||
Add the list of QML files specified by the ``SOURCES`` argument as source files
|
||||
Adds the list of QML files specified by the ``SOURCES`` argument as source files
|
||||
to the QML module target ``<target>``.
|
||||
|
||||
If the optional ``VERSION`` argument is specified, all QML files will be added
|
||||
@@ -128,20 +188,24 @@ to ``qt_target_qml_sources()``.
|
||||
[EXPORT <export-set>] # Added for 6.8 when using Qt 6
|
||||
)
|
||||
|
||||
Finalize the specified QML module target. This must be called after all other
|
||||
setup (like adding sources) on the target has been done. It will perform a
|
||||
number of tasks:
|
||||
Finalizes the specified QML module target.
|
||||
|
||||
This is required in case you do not use the executable as backing target.
|
||||
|
||||
This must be called after all other setup (like adding sources) on the target
|
||||
has been done. It will perform a number of tasks:
|
||||
|
||||
- It will generate a qmldir file from the QML files added to the target. If the
|
||||
module has a C++ plugin, this will also be included in the qmldir file.
|
||||
- If ``BUILD_SHARED_LIBS`` is off, a QRC file is generated from the QML files
|
||||
added to the target. This QRC file will be included when compiling the C++ QML
|
||||
module. The built static library will be installed in a subdirection of
|
||||
``DESTINATION`` based on the QML module's uri. If this value is not set, KDE_INSTALL_QMLDIR will be used.
|
||||
Note that if ``NO_PLUGIN`` is set, a C++ QML plugin will be generated to include the QRC files.
|
||||
- If ``BUILD_SHARED_LIBS`` in on, all generated files, QML sources and the C++
|
||||
plugin will be installed in a subdirectory of ``DESTINATION`` based upon the
|
||||
QML module's uri. In addition, these files will also be copied to the target's
|
||||
module. The built static library will be installed in a subdirectory of
|
||||
``DESTINATION`` based on the QML module's URI. If this value is not set,
|
||||
KDE_INSTALL_QMLDIR will be used. Note that if ``NO_PLUGIN`` is set, a C++
|
||||
QML plugin will be generated to include the QRC files.
|
||||
- If ``BUILD_SHARED_LIBS`` is on, all generated files, QML sources and the C++
|
||||
plugin will be installed in a subdirectory of ``DESTINATION`` based on the
|
||||
QML module's URI. In addition, these files will also be copied to the target's
|
||||
``RUNTIME_OUTPUT_DIRECTORY`` in a similar subdirectory.
|
||||
- If ``BUILD_SHARED_LIBS`` is off, ``EXPORT`` allows to specify a CMake export set
|
||||
all installed targets should be added to.
|
||||
@@ -157,10 +221,20 @@ default to ``PROJECT_VERSION`` and which will write a file that is used by
|
||||
|
||||
Since 6.1.0
|
||||
|
||||
Enabling the option ``VERBOSE_QML_COMPILER`` will activate verbose output for qmlcachegen.
|
||||
Enabling the global option ``VERBOSE_QML_COMPILER`` during CMake configuration
|
||||
will activate verbose output for qmlcachegen.
|
||||
|
||||
Since 6.18.0
|
||||
|
||||
Generate code from qmlcachegen is put into the same ``UNITY_GROUP``. Unity builds
|
||||
using this can either be activated manually per target or with the ``ECM_QMLCACHE_UNITY_BUILD``
|
||||
option globally. This can speed up clean builds at the expense of needing more memory
|
||||
and making incremental builds slower.
|
||||
|
||||
#]========================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/QtVersionOption.cmake)
|
||||
|
||||
# This is also used by ECMFindQmlModule, so needs to be available for both
|
||||
|
||||
Reference in New Issue
Block a user