PDA

View Full Version : qmake project dependencies



akos.maroy
15th June 2008, 13:28
I'm looking at the qmake documentation, but I'm having troulbe seeing how I can make qmake work in the following context.

I'm having a range of libraries and some executables, all in separate projects. I want each project do mark the other as a dependency, and build it if needed. What would be even better if projects could export some of their properties, like include file paths, to project that depend on them, so that it's sufficient to just specify the project dependency to have everything set to build the project.

for example, consider the following directory structure:



root
|-- app1
|-- app2
|-- lib1
| |-- include (lib1 public include files)
| ...
| `-- lib (lib1 target build directory, containing the built libraries)
`-- lib2
|-- include (lib2 public include files)
...
`-- lib (lib2 target build directory, containing the built libraries)


and for the sake of the example, app1 would depend on lib2, which in turn depends on lib1. app2 depends on lib1 alone.

as far as I got, one has to manually add the following to app1's project files:



INCLUDEPATH += ../lib2/include ../lib1/include
LIBS += -L../lib2/lib -llib2 -L../lib1/lib -llib1


and for app2:



INCLUDEPATH += ../lib1/include
LIBS += -L../lib1/lib -llib1


and for lib2:



INCLUDEPATH += ../lib1/include
LIBS += -L../lib1/lib -llib1



why I'd be looking for a qmake-based solution, that would enable just noting an external library are the following:


to have a single point for marking dependencies (vs. marking includepath, libs, etc. all separately, which is prone to human error and a duplication of paths)
to propagate dependency tree information (e.g. in the above example, lib2 could propagate the dependency details for lib1 up to app1)
makeing full dependency-aware rebuilds (e.g. changes in lib1 could trigger a rebuild in app1, lib2 and app2 as well)


with a possible qmake-based solution, would could use the following in app1:



DEPENDS_ON = ../lib2/lib2.pro


for lib2:



DEPENDS_ON = ../lib1/lib1.pro
EXPORT_INCLUDEPATH += include
EXPORT_LIBS += -llib1


for lib1:



EXPORT_INCLUDEPATH += include
EXPORT_LIBS += -llib2



maybe this is all there, and I'm just not finding it in the documentation? maybe none if this is there?

jpn
15th June 2008, 13:52
See Qt Centre wiki: Undocumented qmake (notice especially paragraph "SUBDIRS projects").