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
Subdirs
project there is a.depends
parameter one can give to each project. HoweverSubdirs
project can contain otherSubdirs
projects 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 1
There are two issues with this setup:
-
One cannot set the dependencies in
Master Subdirs
because neitherProject 2
orProject 1
are known to it (similarly forSubdirs 2
). The only thing that can be set is whetherSubdirs 2
depends onSubdirs 1
but that will not help if there are mutual dependencies. -
When building
Project 2
on its own it does not know about its dependencies set in theSubdirs
project and since projects inSubdirs
cannot 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
Subdirs
but 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+=ordered
As 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.