[CMake] Question about transitive dependencies

Bill Hoffman bill.hoffman at kitware.com
Thu Dec 4 16:38:28 EST 2008


Robert Dailey wrote:
> Hi,
> 
> Currently I have 3 projects named A, B, and C. A and B are both static 
> libraries, and C is an executable. B depends on A, and C depends on B 
> via add_dependencies(). When I generate a visual studio 9 project from 
> this setup, how will the libraries be linked? The way I want this to 
> work is for C to link against both A and B, and B will not link against 
> A (Since B's dependencies should transfer to C). Is there a way to 
> accomplish this behavior? I want to avoid using target_link_libraries 
> for the most part because it's redundant. I'm already specifying B as a 
> dependency of C through add_dependency(), why should I have to list B's 
> static library file as a dependency of C's executable? Can't CMake pull 
> this information from the call to add_dependency()?
> 

Sounds like you should be using target_link_libraries instead of 
add_dependency.

-Bill


More information about the CMake mailing list