[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, 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 : )
-
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 :(
-
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 "A.pro", "B.pro" and "C.pro". 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 "Subdirs.pro".
In that profile you add:
TEMPLATE = subdirs SUBDIRS = A \ B \ C
When you build "Subdirs.pro", everything will be built. Hope this helps. By the way, check this link:
http://stackoverflow.com/questions/1417776/how-to-use-qmakes-subdirs-template
-
@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:https://www.toptal.com/qt/vital-guide-qmake
https://wiki.qt.io/QMake-top-level-srcdir-and-builddir
Which helped me set up a working example: https://github.com/219-design/qt-qml-project-template-with-ci/blob/6af6488d74e1dc97a/main_gui.pro