In Qt
you can create nested projects, for which you have to define the main project as SUBDIRS
. Apart from this configuration, the main project does not support many more modifications.
If you want to share, for example, configuration files (.pri) between the different subprojects, you can choose several ways:
- Indicate the absolute path to the file. The disadvantage of this mechanism is that it can cause problems when working in a group, since you force everyone to have the projects in the same place.
- Indicate the path relative to the file. The disadvantage of this system lies in the fact that each subproject can host more subprojects, which makes it necessary to indicate a different route for each project.
- Storing the path in a system variable, which forces you to create, edit, and maintain the system variable, usually by hand.
Ideally, you would be able to determine the path from the location of the parent project and make that information accessible to all projects. What has been commented here could be extended to any type of values to be shared between the different projects (version information, manifest, ...)
Isn't there a slightly more elegant mechanism for sharing information in the context of nested projects?
If you use Qt5 consider
.qmake.conf
in the main project you could define the variables liketop_srcdir
:If you use Qt4 you have to use
.qmake.cache
autogenerated.qmake.cache.in
Look more here (in English).
With this solution you could use path No.1 but without knowing the exact path of the main project.