[CMake] Linking to libraries that depend on other libraries

Petr Kmoch petr.kmoch at gmail.com
Thu May 17 02:18:10 EDT 2012


Hi David,

there's a target property LINK_INTERFACE_LIBRARIES (and
per-configuration variants) which can be used for this purpose.
Starting with 2.8.7, target_link_libraries() also accepts
LINK_INTERFACE_LIBRARIES as a new argument mode, setting the property
instead of linking.

Petr

On Wed, May 16, 2012 at 11:19 PM, David Doria <daviddoria at gmail.com> wrote:
> I have a library, libA, that depends on another library, libB, with
> this structure:
>
> My Program -> libA -> libB
>
> In my program, if I only link to libA, I get linker errors that it
> can't find things in libB, and these errors are fixed if I also link
> My Program to libB. This makes sense, but is there any way to avoid it
> with CMake? That is, a command that I can put in libA (created with
> add_library) that says "when something links to me (libA),
> also/automatically link it to libB"?
>
> Thanks,
>
> David
> --
>
> 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