[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    [CMake] Library deduplication and imported target dependencies
From:       Stefano Bonicatti <smjert () gmail ! com>
Date:       2016-05-30 12:15:47
Message-ID: CAGMAV4-yTWT4YQXFOft53ws_NRpB4FPfLoNAyu=wyt8F7EaHTg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello there.
First of all is there any documentation about how CMake handles
deduplication of libraries when linking (so to avoid duplicate libraries to
be linked unnecessarily)?

Now to my issue: I have a library libA which has to link to libB, libC,
libD and libE.
libA is the only one internal to the CMake buildsystem, the other ones are
all external, and all are shared libs.
i obtain libB, libC and libD by path (find_package) and libE is an imported
target (added with add_library(libE SHARED IMPORTED)).

libE is actually compiled through custom commands and have dependencies
that i've set with set_target_properties(libE PROPERTIES
INTERFACE_LINK_LIBRARIES "${LIBRARY_DEPS}").

The deps are libC, libD, libF, libG and they're set with set(LIBRARY_DEPS
${LIBC} ${LIBD} ${LIBF} ${LIBG}).

Now if i look at the libA link command line, i see libC and libD duplicated.

The libs libA needs are linked with target_link_libraries and, except for
libE which is a target, they are all specified as absolute paths.

Now i've also tried removing the quotes around ${LIBRARY_DEPS}, when using
it, but this time while it deduplicates libC and libD, libF and libG aren't
linked anymore...

I've also tried creating imported targets for libC and libD, using them in
libA target_link_libraries (while still specifing the absolute path for
INTERFACE_LINK_LIBRARIES of libE), but it still doesn't deduplicate them.

Any clue?

[Attachment #5 (text/html)]

<div dir="ltr">Hello there.<div>First of all is there any documentation about how \
CMake handles deduplication of libraries when linking (so to avoid duplicate \
libraries to be linked unnecessarily)?</div><div><br></div><div>Now to my issue: I \
have a library libA which has to link to libB, libC, libD and libE.</div><div>libA is \
the only one internal to the CMake buildsystem, the other ones are all external, and \
all are shared libs.</div><div>i obtain libB, libC and libD by path (find_package) \
and libE is an imported target (added with add_library(libE SHARED \
IMPORTED)).</div><div><br></div><div>libE is actually compiled through custom \
commands and have dependencies that i&#39;ve set with set_target_properties(libE \
PROPERTIES INTERFACE_LINK_LIBRARIES \
&quot;${LIBRARY_DEPS}&quot;).</div><div><br></div><div>The deps are libC, libD, libF, \
libG and they&#39;re set with set(LIBRARY_DEPS ${LIBC} ${LIBD} ${LIBF} \
${LIBG}).</div><div><br></div><div>Now if i look at the libA link command line, i see \
libC and libD duplicated.</div><div><br></div><div>The libs libA needs are linked \
with target_link_libraries and, except for libE which is a target, they are all \
specified as absolute paths.</div><div><br></div><div>Now i&#39;ve also tried \
removing the quotes around ${LIBRARY_DEPS}, when using it, but this time while it \
deduplicates libC and libD, libF and libG aren&#39;t linked \
anymore...</div><div><br></div><div>I&#39;ve also tried creating imported targets for \
libC and libD, using them in libA target_link_libraries (while still specifing the \
absolute path for INTERFACE_LINK_LIBRARIES of libE), but it still doesn&#39;t \
deduplicate them.</div><div><br></div><div>Any clue?</div></div>



-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: \
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information \
on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic