[CMake] third party library dependencies

Adolfo Rodríguez Tsouroukdissian adolfo.rodriguez at pal-robotics.com
Fri Dec 18 04:48:11 EST 2009


On Fri, Dec 18, 2009 at 10:19 AM, Marcel Loose <loose at astron.nl> wrote:

> 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})
>

I've had to deal with this issue and Marcel's proposal is what I do. There
is one slight gotcha that I haven't resolved cleanly yet. Suppose that
A_LIBRARIES depends on certain Boost components, so inside FindA.cmake I
perform a

find_package(Boost REQUIRED COMPONENTS xxx yyy)

and append Boost_LIBRARIES to A_LIBRARIES. Note: I use find_package instead
of hardcoding the library names so that libraries appear as fully qualified
paths, and nonstandard installation paths can be used. Everything OK for
now.

Now, in my project, which depends on A and some other Boost component I do

find_package(A)
find_package(Boost REQUIRED COMPONENTS zzz)

What happens is that since Boost was already found in A, the zzz component
is not included in Boost_LIBRARIES. Has anybody found a successful way of
dealing with this?

TIA,

Adolfo



> 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
>
> _______________________________________________
> 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
>



-- 
Adolfo Rodríguez Tsouroukdissian, Ph. D.

Robotics engineer
PAL ROBOTICS S.L
http://www.pal-robotics.com
Tel. +34.93.414.53.47
Fax.+34.93.209.11.09
AVISO DE CONFIDENCIALIDAD: Este mensaje y sus documentos adjuntos, pueden
contener información privilegiada y/o confidencial que está dirigida
exclusivamente a su destinatario. Si usted recibe este mensaje y no es el
destinatario indicado, o el empleado encargado de su entrega a dicha
persona, por favor, notifíquelo inmediatamente y remita el mensaje original
a la dirección de correo electrónico indicada. Cualquier copia, uso o
distribución no autorizados de esta comunicación queda estrictamente
prohibida.

CONFIDENTIALITY NOTICE: This e-mail and the accompanying document(s) may
contain confidential information which is privileged and intended only for
the individual or entity to whom they are addressed.  If you are not the
intended recipient, you are hereby notified that any disclosure, copying,
distribution or use of this e-mail and/or accompanying document(s) is
strictly prohibited.  If you have received this e-mail in error, please
immediately notify the sender at the above e-mail address.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091218/2876b20c/attachment-0001.htm>


More information about the CMake mailing list