Qt World Summit: Register Today!

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. 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.

  • Moderators

    I've got one hint, although it may not be exactly what you are looking for. Add this in your .pro file:


    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.

  • Lifetime Qt Champion


    In addition to @sierdzio, take a look at this nice article on how to setup dependencies between subprojects.

  • Moderators

    Good info, @SGaist thanks :-) That link goes straight to my bookmarks.