Congratulations to our 2022 Qt Champions!

[solved] Create top level QT project to build multiple projects

  • I have two completely separate qt projects (maybe more in future):

    • \somewhere\qtProj1\
    • \somewhere\qtProj2\

    However they are both a part of a larger system, so I want to create a "top-level" project that is only there to build the various projects and copy the various outputs to a single location. I would like to end up with:

    • \somewhere\qtMain\ (this project may just contain a .pro file - not really sure)
    • \somewhere\qtProj1\
    • \somewhere\qtProj2\

    So the idea is, that I open qtMain, select the build type (debug, release, etc...) and the hit "build". It then builds all the referenced projects (i.e. qtProj1 and qtProj2) with the relevant CONFIG options.

    I looked at the Qt subdirs project, but this does not look like what I want. Is there some way to do this? In make/scons you just call the "sub projects" make/scons files. I just want something simple/basic.

  • Hi,

    I suggest to use CMake for complex projects.

    At the moment I manage a big system composed by 10 executables and more than 300 Unit Test in a single CMake projects.

  • Hi, thanks for that.

    My project is not very complicated as such and I never used CMake. I would prefer to do this in the Qt environment - but if its not possible then I will try CMake : )

  • Hi,

    I don't know if with qMake is NOT POSSIBLE; for sure CMake is more flexible and powerful.

    The good thing about leaning CMake is that you can use it also for non-Qt projects

  • Have you looked at the "Subdirs project"? It might be what you are looking for.

  • @mcosta Thanks for the advice, I will look into CMake : )

  • @t3685 I mentioned in my original mail that subdirs project does not appear to be what I want (as far as I read about them and tested with them).

  • Unless I very misunderstood what you want, the subdirs project is you are looking for.
    We have a Subdirs project, which consists of all the libraries we have + the applications which depend on them as sub-projects.
    Sorry for not reading your first post properly by the way.

  • @t3685 No worries, I just didn't want you to think I had not done any research! ...

    So I don't quite see how this works with sub-dirs project. I am not adding a new project and I am not adding a library - there does not seem to be an option to add an existing project. Can you show a link to an example?

    All I want the "main" project to do is build a list of other projects with "CONFIG+=a b c"

    In Sub Dirs project I can add libraries, or new projects I can't see how to do an existing one :(

  • @code_fodder

    I took me a while to wrap me head around the Subdirs project at first. Basically the subdirs projects in a subdir project are just regular Qt qmake projects. The subdirs project itself is just a collection of those projects.

    For example, say you have project A, B and C in folder "A", "B" and "C" with the following pro files "", "" and "". To create a subdirs project you move the folder "A", "B" and "C" to one folder (e.g. "Subdirs"). In "Subdirs" you make your subdirs pro file "".

    In that profile you add:

    TEMPLATE = subdirs
    SUBDIRS = A \
              B \

    When you build "", everything will be built. Hope this helps. By the way, check this link:

  • @t3685 ahhhh, so simple!, I was trying to use the wizards to add projects - it literally is just a .pro file with a list of sub-dirs where the next level of .pro files are! - I am sure they don't explain it in those simple terms in the docs : (

    Thanks for persevering with your answer, up-voted accordingly : )

  • Another post recently linked back to this one, so I wanted to augment this with a couple more relevant links for setting up a manageable, maintainable qmake SUBDIRS structure:

    Which helped me set up a working example:

Log in to reply