[CMake] Question about transitive dependencies

Alexander Neundorf a.neundorf-work at gmx.net
Thu Dec 4 16:35:32 EST 2008


On Thursday 04 December 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()?

target_link_libraries(B A)
...
target_link_libraries(C B)

should do it.
Doesn't it ?

Alex


More information about the CMake mailing list