[Interest] Porting a previous qmake approach to cmake

Nuno Santos nuno.santos at imaginando.pt
Fri Jan 13 17:28:29 CET 2023


Still related with the issue https://bugreports.qt.io/browse/QTBUG-110110

What I’m really trying to achieve here follows attached in a very minimal example.

For our applications we have a shared ground which would compile as a static lib without any requirement of a plugin. This lib is full of shared resources such as icons, images, qml, etc.

Then, each application has also a static lib called common, which also has icons, images, qml, etc.

Then each application which can have have up to 4 different targets will link static with this lib. We are doing audio plugins in most cases, which mean they are bundled as a single library (eg:  a single dll on Windows).

While developing an app I want to be able to run in debug and compile all the sources at once with the hassle of building each lib. 

When doing a release build I usually want to build the shared and common libs first and then build the targets, linking with those libs.

This is what I’m trying to achieve in the structure of the project below. 

It seems that to take full advantage of the qml compiling with cmake we can run to qt_add_qml_module. My biggest deal right now is how to glue things together. 

In this example if I compile in debug the application fails to launch because it says:

qrc:/Common/qml/main.qml:3:1: module "CommonModule" is not installed
qrc:/Common/qml/main.qml:2:1: module "SharedModule" is not installed

If I switch to release I need to have common compiled and installed, which will also compile and install shared. So what I’m doing is going to the build directory of common and call cmake —install .

When I do that, I realise that libcommonplugin.a and libsharedplugin.a are not installed and I don’t understand why. So I need to manually copy this two items to the install folder in order to be able to install the application.

➜  build-common-Qt_6_4_2_for_macOS-Debug cp libcommonplugin.a ../common/build/lib
➜  build-common-Qt_6_4_2_for_macOS-Debug cp shared/libsharedplugin.a ../common/build/lib

When running the app in release the qml resources that are in shared and common static libs are not registered and therefore not available.

I’ve been here all week trying to figure out the solution for this problem and any help would be amazing.

Thank you very much!

Best regards,


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230113/92290b69/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-project-with-shared-libs.zip
Type: application/zip
Size: 21680 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230113/92290b69/attachment.zip>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230113/92290b69/attachment-0001.htm>

More information about the Interest mailing list