[Interest] What is the right way of creating a static lib that has qml resources with cmake?

Ulf Hermann ulf.hermann at qt.io
Wed Jan 11 16:43:19 CET 2023


> With the following approach two libs are created:
>
> libshared.a and libsharedplugin.a
>
> I just want to have a single target called libshared.a with all the qml resources embedded.

You can add NO_PLUGIN to your qt_add_qml_module, but be warned: The 
linker will be clever and omit your type registrations. You have to 
prevent that in some other way then. The usual way to prevent it is 
Q_IMPORT_PLUGIN on the generated plugin.

And you should not add your QML files with qt_add_resources. The most 
important thing qt_add_qml_module does is adding your QML files.

best regards,

Ulf



More information about the Interest mailing list