Working with software that uses QML

QML is an interpreted language, that is only executed if the application is executed. That makes it hard to detect the correct QML dependencies at build time. To help with the detection of the QML runtime dependencies, there is dh_qmldeps. dh_qmldeps is shipped in pkg-kde-tools. It basically uses qmlimportscanner to get the QML dependencies for QML files.

Using dh_qmldeps

You simple add at your control file for build-depends dh-sequence-qmldeps. Add to all binary packages in Depends: ${qml6:Depends} or ${qml5:Depends}, depending on the Qt version. If you build a QML module you should add the module package to the dev package, so dh_qmldeps can detect QML dependencies.

You want to see some examples that already using dh_qmldeps?

dh_qmldeps will detect, if you create a QML module and checks the qmldir file for dependencies. It allows inter-package dependencies on the created QML module. To simplify the QML detection for QML application, that only has one single binary package, dh_qmldeps will fall back to search QML files in the source package.

FAQ

dh_qmldeps complains about missing QML dependencies?

I: dh_qmldeps dh_qmldeps:94: Execute /usr/bin/pkgkde-getqmldepends -p itinerary --qt 6 -- -qmlFiles ...
E: dh_qmldeps qmldeps:304: Missing QML module org.kde.kirigamiaddons.formcard
E: dh_qmldeps dh_qmldeps:100: /usr/bin/pkgkde-getqmldepends failed with 1.
You need to add the corresponding QML module to Build-Depends, as dh_qmldeps can only detected installed QML modules, as it cannot guess the package name. You can run pkgkde-getqmldepends --apt-file [...](if you have configured apt-file), to search via the apt-file cache for the missing QML modules. To not list every QML dependency in Build-Depends, the dev packages of a QML module should install the QML module itself. If you installed the corresponding -dev package, file a bug against the source package, in order to fix it.

dh_qmldeps complains about internal QML dependencies?

I: dh_qmldeps dh_qmldeps:94: Execute /usr/bin/pkgkde-getqmldepends -p neochat --qt 6 -- -qmlFiles ...
E: dh_qmldeps qmldeps:304: Missing QML module org.kde.neochat
E: dh_qmldeps dh_qmldeps:100: /usr/bin/pkgkde-getqmldepends failed with 1.
Create the file qmldeps.overrides and add a line: QML.module debian-pkg, debian-pkg2 (>= 0.1.2) For the example:
org.kde.neochat neochat
From the logs it looks like "just a normal missing dependency". You can distinguish the two issues only be looking into the code. In this example you can see the usage of ecm_add_qml_module in CMakeLists.txt.

dh_qmldeps does not recognize the QML files in package

E: dh_qmldeps dh_qmldeps:103: kosmindoormap-demo: No automatic qml files found for package you need to add the files by hand to debian/kosmindoormap-demo.qmlfiles
Create the file <pkg>.qmlfiles and add the needed arguments for qmlimportscanner to work on the correct qml files. Automatically dh_qmldeps only search for *qml files in the binary package.