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. DOCS However Subdirs
project can contain other Subdirs
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:
1) One cannot set the dependencies in Master Subdirs
because neither Project 2
or Project 1
are known to it (similarly for Subdirs 2
). The only thing that can be set is whether Subdirs 2
depends on Subdirs 1
but that will not help if there are mutual dependencies.
2) When building Project 2
on its own it does not know about its dependencies set in the Subdirs
project and since projects in Subdirs
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.
Your assessment is basically correct.
1) You can only set dependencies in a subdirs .pro file between projects that are children of this subdirs .pro file, so to make Project 2
dependent on Project 1
you either need to make Subdirs 2
dependent on Subdirs 1
or get rid of the child subdirs.
2) To build Project 2
while regarding the dependency on Project 1
you either have to build Master Subdirs
, or, if you opened Project 1
and Project 2
as individual projects in Qt Creator, you need to configure the dependency in the Dependencies
tab under the project configuration for Project 2
.