[CMake] third party library dependencies

Marcel Loose loose at astron.nl
Fri Dec 18 04:19:05 EST 2009


Hi Roman,

Not in a portable way. I'm not too familiar with Windows, but on Linux
you can do this when libA is a shared library that has its dependency on
libB linked in (e.g. ldd libA.so will tell you this). When linking in
static libraries you're out of luck. 

I would write a FindA.cmake file for this and let that macro set the
variable A_LIBRARIES to contain both libA and libB. You can then use:

  find_package(A)
  target_link_libraries(${A_LIBRARIES})

Hope this helps,
Marcel Loose.


On Thu, 2009-12-17 at 12:18 -0500, Roman Shtylman wrote:
> Is there an easy way to setup link dependencies between libraries not
> build using cmake?
> 
> Lets say I have a system library A which depends on system library B.
> I then make an executable that uses code from A. I need to link
> against A and B, but as a user of just library A, I don't want to
> worry about that. Does cmake have a facility to define such a
> hierarchy/dependency chain so that I can just do
> 
> target_link_libraries(<target> A)
> 
> and have it figure out that it needs to link against B as well?
> 
> Note that neither A nor B are built using cmake, they already exist.
> 
> ~Roman
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list