PDA

View Full Version : making Eclipse recognize project dependnecies with qmake?



akos.maroy
18th January 2009, 18:04
I'm using a setup where I'm describing my projects using qmake project files, and generate GNU Makefiles based on these. I'm using Eclipse CDT as an IDE, but unfortunately it does not recognize cross-project dependencies.

for example, I have a range of libraries as separate projects, and then a range of executables that depend on various libraries. libraries may also depend on other libraries.

because Eclipse does not recognize the dependencies, whenever I change something in a library and build it, I have to clean and re-build dependent applications afterwards. this is rather inconvenient.

is there a 'proper' way to specify library dependencies in qmake project files? even in a way that would be recognized by Eclipse aftewards?

wysota
19th January 2009, 08:27
This is a very hard thing to achieve, because you are depending on a library (*.so, *.a) from another project, which is fine. But the library itself depends on its source files and possibly on other libraries. Unless you monitor changes to all these files there is not much you can do. What you can do is to force calling make each time on every dependent library so that make checks those. You can do that through qmake's system() function.

akos.maroy
19th January 2009, 08:55
This is a very hard thing to achieve, because you are depending on a library (*.so, *.a) from another project, which is fine. But the library itself depends on its source files and possibly on other libraries. Unless you monitor changes to all these files there is not much you can do.

I'm not sure this is true. The library will be recompiled anyway, because some if its source files changed. then the library will have a newer timestamp than the executable that depends on it.

currently, this is not taken into account, and the executable is not re-linked againts the library. when building the executable, neither the timestamp of the library is taken into account, nor is a make issued for dependent projects.

if this could be achieved, I'd be more than happy :) (and would solve my problems)

wysota
20th January 2009, 08:39
I'm not sure this is true. The library will be recompiled anyway, because some if its source files changed. then the library will have a newer timestamp than the executable that depends on it.
From what I undestood you wanted the library to be recompiled automatically. If that's not the case then there is no problem. Add the library to PRE_TARGETDEPS qmake variable.

akos.maroy
20th January 2009, 11:40
From what I undestood you wanted the library to be recompiled automatically. If that's not the case then there is no problem. Add the library to PRE_TARGETDEPS qmake variable.

thanks for the tips. actually I have had to settle for the following:



LIBS += -L../libFoo/lib -lfoo \
-L../libBar/lib -lbar

INCLUDEPATH += ../libFoo/include ../libBar/include

PRE_TARGETDEPS = ../libFoo ../libBar

DEPENDPATH += $$INCLUDEPATH


what is strange for me here is that basically I have do define my dependencies twice in a way. after all, I already specify where to find include files & where my libraries are. and then I have to specify again that I actually depend on those include files & libraries. for me this seems kind of obvious - if I include or link something, I depend on it :)

wysota
20th January 2009, 13:05
I can tell you that you can find elephants in Africa, but that doesn't yet determine you actually need to find an elephant right now.