[CMake] Question about transitive deps and static libs.

Eric Noulard eric.noulard at gmail.com
Tue Apr 18 10:30:06 EDT 2017


I have a question concerning the transitive linking of dependence and
static libs.

I'm working a on prokect where some shared lib are linked to static lib (do
not ask me why).
So I do:

set(CMAKE_POSITION_INDEPENDENT_CODE True)

then I have a bunch of libraries (either static or shared) which depends on
each other.
I use PRIVATE and PUBLIC specification with target_link_librairies.

Now I expected that the transitive link properties would be fullfilled
simply i.e. that
when some target LIB1 is PRIVATEly link against say pthread. Then if a
another
lib LIB2 is linked against LIB1 then then "pthread" wouldn't be dragged
into the link
interface of LIB2.

It seems that this is not as simple as I thought and as soon as LIB1 is
static
then LIB2 gets the dependency (be it PRIVATE or PUBLIC)...

Find attached a small example.

Is this a bug, a feature or something I didn't catch?


-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170418/96e949e0/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: privpubdeps.tgz
Type: application/x-gzip
Size: 554 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170418/96e949e0/attachment.bin>


More information about the CMake mailing list