Installing a reusable QML module
-
Hello,
I'm looking for some guidance on how to create a reusable QML module with CMake.
So let's say I want to create a module "MyReusableThing" that would have a few cpp files marked with QML_ELEMENT and several reusable .qml components.
As I understand I will get a "backing" library, plugin library, qmldir and .qmltypes.
So I start by callingqt_add_qml_module(MyReusableThing SHARED URI "MyReusableThing" RESOURCE_PREFIX "/" SOURCES a.cpp b.cpp # etc. QML_FILES Comp1.qml Comp2.qml # etc. )
How should I then proceed to create an "installation"?
E.g. I install it toD:/libs/MyReusableThing/
Where I would expect to find something like:lib/MyReusableThing.dll cmake/...
and then I also expect I can see something similar to what one can find in Qt install dir:
qml/MyReusableThing/qmldir qml/MyReusableThing/MyReusableThingplugin.dll qml/MyReusableThing/MyReusableThing.qmltypes qml/MyReusableThing/Comp1.qml qml/MyReusableThing/Comp2.qml
The goal I want to achieve is to create new CMake project that would consume this "library". So then I think I would add
D:/libs/MyReusableThing/qml/
to QML_IMPORT_PATH andD:/libs/MyReusableThing/
to my CMAKE_PREFIX_PATHAnd in the consuming module I would just write
find_package(MyReusableThing REQUIRED CONFIG)
and linkMyReusableThing::MyReusableThing
to the app (backing library?)In my QML files I would presumably just use Comp1 and Comp2 and the deploy script would take care of the rest. To copy them to the "deploy" dir.
How can I achieve this, or what is an "official" way of doing things like this? When I search the internet I always find self-contained monolithic projects.
Thank you for insights :)