I have a project with 5-6 libraries and one executable. The executable depends on the libraries, and some libraries depend on other libraries. How can I specify a build order so the dependencies are built before they are needed?
Update: (Feb 2021)
Please consume the advice in the (old) answer below in light of this new information.
Although this question has been answered and accepted a long time ago, I feel the need to add another answer; I honestly think that there is a better answer.
I consider CONFIG += ordered
harmful and a bad habit. It is probably something that was a bit prematurely introduced by the qmake developers. And there are strong opponents to its use. The drawbacks are these:
Therefore, I suggest to change your project file as follows:
TEMPLATE = subdirs
SUBDIRS += Utility GraphicModule PackingLib Core GameProto
GameProto.depends = Core
Core.depends = PackingLib
PackingLib.depends = GraphicModule
GraphicModule.depends = Utility
This way the dependencies are clearly defined. You can also think of other, more complicated dependency hierarchies which are possible this way and absolutely impossible with the build order.
Unfortunately, qmake
is not the best tool when it comes to larger projects with deep sub-project hierarchies. Problems seen with larger projects are these:
Run qmake
takes an extremely long time to executeqmake
is not able to correctly calculate sub-project dependencies which makes it necessary to compile sub-projects separatelyThere mainly two ways to address these issues:
qmake
run times and shorter compilation times. However, even this approach may fail at times.cmake
. Seriously. Cmake
is a mature product and the support from within Qt Creator is comparable to qmake
.Because of the well known problems with qmake
, the Qt Company has already decided to introduce a new make tool QBS
. However, the use of this tool is not as simple as it may look on first impression. There is no easy transition from qmake
to QBS
, especially for more complex projects. The Javascript-like syntax of the QBS
language is not easy to grasp and documentation is scarce.
There are IMHO only two other tools available that are of the caliber to replace qmake
:
CMake
, the well known build tool.meson
, an open source build system meant to be both extremely fast, and, even more importantly, as user friendly as possible.Ok. I found the solution.Just add ordered to CONFIG and recite subdirs in correct order
CONFIG += ordered
SUBDIRS += Utility GraphicModule PackingLib Core GameProto
For me this work fine
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With