Details
-
Task
-
Resolution: Done
-
P2: Important
-
6.1.0 Beta 1
-
1c4ba17015fe99da48ce73fab75ecc60cf9cb975 (qt/qtdeclarative/dev)
Description
A QML-friendly library should come with metatype generation enabled by default, the include directories set up so that any type registrations can be compiled, an option to enable QML type registration, a nice way to add linked libraries, and possibly more. I currently have to do this (and I don't know if it actually works):
add_library(QmlBench STATIC qmlbench.cpp qmlbench.h testmodel.cpp testmodel.h qquickviewforeign.h ) target_link_libraries(QmlBench PRIVATE Qt::Core Qt::Qml Qt::Gui Qt::Quick ) target_include_directories(QmlBench PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> ) set_target_properties(QmlBench PROPERTIES QT_QML_MODULE_URI "QmlBench" QT_QML_MODULE_VERSION ${CMAKE_PROJECT_VERSION} ) qt_enable_autogen_tool(QmlBench "moc" ON) qt_extract_metatypes(QmlBench) qt_qml_type_registration(QmlBench)
QML-friendly should be the default for any Qt-based library. So, it should be called something generic like "qt_add_library".
Furthermore, qt_add_qml_files should be able to attach QML files to any QML-friendly target. This is necessary for QML modules with QML files to have optional plugins: We need to compile the qmlcachegen-processed QML files into a library the plugin can link. The plugin should be an empty shell that only loads such a base library.
For example, the QtTest import has a few QML files. The fact that it's currently optional means the plugin might not be loaded at all. Therefore, the qmlcachegen-compiled variants of the QML files may not be available at run time. This is not great as they will then be re-compiled on each invocation of any application that uses them.
Instead, the QML files should be compiled into libQtQuickTest.so. If the user application links libQtQuickTest.so, the plugin won't be loaded. If the QML files are in libQtQuickTest.so, rather than in the plugin, they will still be available.
Attachments
Issue Links
- relates to
-
QTBUG-82598 Establish a public API for building static QML plugins
- Closed
-
QTBUG-88763 Review / refactor public CMake API that is marked as Technical Preview
- Closed
-
QTBUG-89274 Make public, documented API for compile time QML type registration with CMake
- Closed
-
QTBUG-94396 Adapt to latest qml CMake API
- Closed