[Cmake] Problems with Library Dependencies

Rainer Michael Schmid rms at outside-of-the-asylum.de
Tue, 6 Apr 2004 18:02:40 +0200


> CMake only depends on libraries that it can build.   You can
> link other libraries, but right now it does not depend on them.
> So, if there is not an ADD_LIBRARY in the project, the library
> will not be in the DEPEND_LIBS.

This reminds me of a problem I currently have -- actually, my problem 
is unrelated to this one, but I had to think of it...

I have a directory "autotest" with the subdirectories "node" and 
"parser". In the subdirectories "node" and "parser" I build static 
libraries. The "autotest" directory also builds the executable.

So the CMakeLists.txt in "autotest" contains (among others):

SUBDIRS(node parser)
LINK_LIBRARIES(node parser)
ADD_EXECUTABLE(autotest  main.cpp)

The "autotest_DEPEND_LIBS" contain the right libraries. But if I change 
something that rebuilds the "node" library, I need to runs of "make" to 
get not only the library rebuilt, but also to relink the "autotest" 
executable.

Is it correct that the problem is that make calculates the dependencies 
for the "Makefile" in "autotest" before it goes into the 
subdirectories?

Is there a way to control this or do I have to create a dummy directory 
with an extra "CMakeLists.txt" that builds the executable and the 
"CMakeLists.txt" in "autotest" contains only SUBDIRS()?

Thanks, Rainer

PS: I am new to cmake (I started using it less than a week ago), but I 
really like it so far. Better than qmake or jam (ant I haven't used so 
far, but the examples I saw looked horrible).