[Interest] Quick Component Library Structure

Jérôme Godbout godboutj at amotus.ca
Thu Dec 6 16:23:44 CET 2018


Do you want your Library to be prebuild or source distributed only (if you want to reach mobile platform the second one is way easier).

I can tell you what I do, I use git submodules to checkout my subrepos (we did make a convention internal for the submodule to be inside the main repos folder to ease the auto include). All submodules come with a generic submodule .pri that add features or include the necessary source for the compilation (you can have multiple .pri for each submodules).

My main project .pro does the include of submodule .pri
AMOTUS_SUBREPOS_PATH = subRepos
AMOTUS_SUBREPOS_NAMES = Amotus_Qt QmlAmotus AmotusStyle Amotus_Android Amotus_Mobile

for(a, AMOTUS_SUBREPOS_NAMES){
    !include($${AMOTUS_SUBREPOS_PATH}/$${a}/pri/$${a}.pri){
        error(Cannot find the sub repos $${AMOTUS_SUBREPOS_PATH}/$${a}/pri/$${a}.pri)
    }
}

So I always have the subrepos into the same folder and then the pri inside the submodule /pri/ folder with the same name as the submodules name for basic features (after that I include the extra I want manually).

The .pri can look like this to easily include the files:

# I remove the /pri/ subfolder from the path and avoid ../ since QtCreator and build sequence get messy with them
AMOTUS_Qt_PATH = $$clean_path($$PWD/..)
INCLUDEPATH += $$AMOTUS_Qt_PATH \

HEADERS += \
    $$AMOTUS_Qt_PATH/I18n.h \
…

I put my qml inside resource and include them for each submodules .pri too. So they become available into the qrc:/// you can also add prefix to avoid module name clash but I personally don’t do it.

It work just fine until you do Android where the lib and java source is a little trickier to manage that way but it’s doable with some special .pri rules and modification to file location.

Hope it help.

From: Interest <interest-bounces at lists.qt-project.org> On Behalf Of Nathan Frana
Sent: December 5, 2018 9:28 PM
To: interest at qt-project.org
Subject: [Interest] Quick Component Library Structure

All,
My head has been spinning after trying to find a way to make quick component libraries work.

I have 3 libraries
Library A - QML and/or C++ Components
Library B - QML and/or C++ Components, dependent on components in A
Library C - QML and/or C++ Components, dependent on components in A

Ideally, each library would be in its own git repository, allowing a developer to clone/submodule the libraries that they need for their applications. Any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181206/abf9c07f/attachment.html>


More information about the Interest mailing list