[CMake] Question about transitive dependencies

Alexander Neundorf a.neundorf-work at gmx.net
Thu Dec 4 17:06:05 EST 2008


On Thursday 04 December 2008, John Doe wrote:
> Hello,
>
> This discussion is based on my knowledge of the Gnu Compiler Collection.
>
> My understanding of the linking process is that B will never link
> against A, because static libraries don't link against other static
> libraries.  Library B will have unresolved symbols when linking C.

That's correct.

> You must therefore add a dependency between C and A.
>
> Therefore:
> C links against B and A
> B doesn't link against anything
> B needs the header information for the functions of A.

That's also correct.
But, if you do in cmake:
target_link_libraries(staticLibB staticLibA)
this will not really link (as it would for a shared lib), but it will 
nevertheless keep track of the dependencies.
So when liking
target_link_libraries(myApp staticLibB)
cmake knows that it has to add staticLibA to the linker command.

Alex


More information about the CMake mailing list