[CMake] Adding dependencies for static libraries

Titus von Boxberg titus at v9g.de
Tue Oct 16 07:20:36 EDT 2012


Am 16.10.2012 12:43, schrieb Robert Bielik:
> Hi all, I haven't found the answer to this: I have a static library A
> that uses static library B, but when I create an executable C I only
> want to link with A.
AFAIK you have to link C also with B.
You might add a target_link_libraries(C B) in C's configuration.

A non portable way to avoid this configuration could be to
use automatic linking directives in A's headers included by C.

>
> In Visual Studio this is accomplished by adding library B to "Additional
> Dependencies" (Librarian/General), but how can I make CMake create that
> dependency ?
When you add B to the Additional Dependencies, C is linked with B.

Actually, "target_link_libraries(C B)" puts B into the
Additional Dependencies of the VC project generated for C.

HTH
Titus



More information about the CMake mailing list