How to properly configure dependencies in Subdirs project?
-
There are several ways how to go about dependencies in Qt Creator. With regular projects there is a dependency tab under the Project configuration. With
Subdirsproject there is a.dependsparameter one can give to each project. HoweverSubdirsproject can contain otherSubdirsprojects and the dependencies can thus span across these with a project under sub-sub-project depends on another that is in different sub-sub-project:Master Subdirs L--- Subdirs 1 L--- Project 1 L--- Subdirs 2 L--- Project 2 //depends on Project 1There are two issues with this setup:
-
One cannot set the dependencies in
Master Subdirsbecause neitherProject 2orProject 1are known to it (similarly forSubdirs 2). The only thing that can be set is whetherSubdirs 2depends onSubdirs 1but that will not help if there are mutual dependencies. -
When building
Project 2on its own it does not know about its dependencies set in theSubdirsproject and since projects inSubdirscannot have regular dependencies set in Project tab one cannot build it automatically and must either build everything or build the dependencies manually before the actual project.
Are there any solutions to these problems? No. 1 can be solved with not using child
Subdirsbut no. 2 is still an issue regardless. -
-
I've got one hint, although it may not be exactly what you are looking for. Add this in your .pro file:
CONFIG+=orderedAs described here, the "ordered" option will ensure that the subprojects are built in the same order they are listed in SUBDIRS variable. So it could help you rearrange the projects so that they are build in the order that satisfies all dependencies.
-
Hi,
In addition to @sierdzio, take a look at this nice article on how to setup dependencies between subprojects.