[CMake] Question about static library linking

Tyler Roscoe tyler at cryptio.net
Mon Feb 2 15:45:12 EST 2009


On Mon, Feb 02, 2009 at 02:36:55PM -0500, Jonathan Fillion wrote:
> I have a dynamic library A that depends on a static library B which in
> turns needs another static library C. Now,
> 
> in B's CMakeList.txt:
> 
> LINK_DIRECTORIES(/path/to/c)
> 
> TARGET_LINK_LIBRARIES(C)
> 
>  
> 
> in A's CMakeList.txt:
> 
> LINK_DIRECTORIES(/path/to/b)
> 
> TARGET_LINK_LIBRARIES(B)
> 
> 
> When I try to compile A, it does try to link with C (ie, I see '-lC'
> when I put CMake in verbose mode), so it tracks the dependency, but
> unfortunately it does not put C's link path (ie, it misses the
> -L/path/to/c).

Have you tried adding LINK_DIRECTORIES(/path/to/c) to A's
CMakeLists.txt?

If you think that's ugly because now A has to know things about B's
dependencies, does A do an add_subdirectory(/path/to/B/CMakeLists.txt)?
This way A can know things about things B depends on and I think those
things will bubble up (or can be made to bubble up) to A.

This is one of the areas of CMake that I don't understand well, so I
might be off-base, but it at least gives you some things to try until
someone smarter comes along :).

tyler


More information about the CMake mailing list