[Interest] Require a qt_finalize_target() call in CMake user projects that use a static Qt

Alexandru Croitor alexandru.croitor at qt.io
Wed May 5 14:20:33 CEST 2021

> On 5. May 2021, at 13:59, Joerg Bornemann <Joerg.Bornemann at qt.io> wrote:
> On 5/5/21 1:32 PM, Marius Kittler wrote:
>> to me the most important point is that I can still stay in control over which
>> plugins are linked against and which not. At best I can turn off pulling
>> plugins automatically completely to avoid bloating my applications and keep my
>> own build system logic for deciding what plugins are needed.
> IIUC what you want to do, you can set the QT_PLUGINS/QT_NO_PLUGINS properties on your target and specify the plugins you want to whitelist/blacklist.
> The code that does this for QtGui, for example, is in lib/cmake/Qt6Gui/Qt6GuiPlugins.cmake.
> Our CMake API clearly lacks documentation, but we're working on it.

Developers shouldn't set those properties manually. It's very likely we'll rename those to be lower case + underscored.

Instead they should use qt_import_plugins(), which will set those properties.

So https://doc.qt.io/qt-6/qt-import-plugins.html should be used.

> I must say that Qt 6 made this harder (in contrast to my heavily patched Qt 5 
> version). I'm not quite sure how to disable pulling plugins automatically and 
> without https://github.com/Martchus/qtutilities/commit/
> 7183ec501c90bfc38538fd7a810533b8a8a78cff Qt's CMake modules pulled in tons of 
> unwanted plugins automatically.

Is your concern about the plugins packages being automatically found and targets are automatically created (so that find_package is run at all), or that they get linked to the final executable / shared library?

And is it about generic qt plugins and/or qml plugins?

qml plugins are not linked in by default, unless qmlimportscanner is call called on the target (via qt_import_qml_plugins), but they are automatically find_package'd.

qt plugins are also find_package'd automatically, but only the default plugins are linked in by default (like with qmake), and the set of plugins can be controlled via qt_import_plugins.

Documentation should be improved, yes. It hasn't been yet, because the APIs are in TP and we weren't sure if the signatures would stay the same.

Also, thanks for the feedback.

More information about the Interest mailing list