QT Creator / qmake project organization question
-
Dear all,
I have got a master project that is composed of several projects in two groups. My problem is that the dependencies are not always respected as I expect.
The structure in Qt Creator spans three levels and is as follows:
Master Master.pro +---Group1 | Group1.pro | +---Project1 | | Project1.pro | +---Helper | Helper.pro +---Group2 Group2.pro +---Project1 | Project1.pro +---Helper | Helper.pro +---Common Common.pro Master.pro: TEMPLATE = subdirs SUBDIRS += \ Group1 \ Group2 Group1.depends = Group2 Group1.pro: TEMPLATE = subdirs SUBDIRS += \ Project1 \ Helper Project1.depends = Helper Project1.pro (in Group1): Project1.depends = Helper Helper.pro (in Group1): TEMPLATE = lib CONFIG += staticlib Group2.pro: TEMPLATE = subdirs SUBDIRS += \ Project1 \ Helper \ Common Helper.depends = Common Project1.depends = Helper Common Project1.pro (in Group2): TEMPLATE = lib DEFINES += PROJECT1_LIBRARY Project1.depends = Helper Common Helper.pro (in Group2): TEMPLATE = lib CONFIG += staticlib Helper.depends = Common Common.pro: TEMPLATE = lib CONFIG += staticlib
My questions are:
-
Is it possible to have a project organization with more than two levels (e.g. main project, project groups and individual projects in the groups)?
-
When I change something in Group2/Common and build Group1/Project1, the changes are not taken into account although I have specified in Master.pro that Group1 depends on Group2 and in Group2.pro that Group2/Project1 depends on Group2/Common. Why is this so? Does the dependency check only work top -> down, i.e. when I build the master project?
-
Is it possible that the mixture of dynamic and static libraries causes the problem? I need both (dynamic libraries that can be called by other programs and static libraries with common methods, GUI elements and so on that I would like to link to the GUI applications)?
-
How would you organize the project that is currently composed of a master project and two groups, where one group contains the GUI applications and the other one the dynamic libraries (that can also be called from other programs)?
I am currently using Qt Creator 4.15.1 and Qt 5.15.2 (open source version) on Windows 10.
Thank you very much for your help!
Kind regards,
Ralf
-
-
Hi,
- Sure you can, Qt is a perfect example of that.
- Can you show an example of project that shows that issue ? If you properly set all dependencies it should build in order.
- Yes you can, do not forget to use PRE_TARGETDEPS when linking to your static libraries.
- You can have one group that are the application which contains the bare minimum and then a second group which will contain all the libraries of your applications.
-
I did experiment with Qt "SUB_DIR" and found the dependencies and level relations hard to manage. I think good knowledge of "make" / qmake and how it relates to (C) code is mandatory. And learning "make" was not part of my goal during my project.
I have ditched "SUB_DIRS" and found that I can manage the "subprojects" without it.
If you can - I would recommend to build sort of dummy skeleton / frame of all all your sub projects and then gradually replace then with real code.
73 es 55 -
Hello SGaist and AnneRanch,
thank you very much for the answers.
I had not specified PRE_TARGETDEPS but when I add this I get the error message "Multiple target patterns. Stop.". I will setup a small project structure (and not all at once) and make tests to see how it works exactly.
Kind regards,
Ralf
-
Dear all,
@SGaist said in QT Creator / qmake project organization question:
do not forget to use PRE_TARGETDEPS when linking to your static libraries.
I suppose this is a typical newbie problem. Not all things are done automagically :-) Of course I had not specified this variable and after adding it the problem was solved.
Thanks again for your help.
Kind regards,
Ralf