[CMake] Question about transitive deps and static libs.

Eric Noulard eric.noulard at gmail.com
Tue Apr 18 11:44:00 EDT 2017


Answering to myself.

This mail by Craig explains a lot:
https://cmake.org/pipermail/cmake/2016-May/063400.html

Sorry for the noise. I guess I have my answer in there.
I'll try to propose a documentation update based on Craig's explanation
because,
https://cmake.org/cmake/help/v3.8/manual/cmake-buildsystem.7.html#transitive-usage-requirements

does not contains clues on specific treatment for static libs.




2017-04-18 16:30 GMT+02:00 Eric Noulard <eric.noulard at gmail.com>:

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



-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170418/aa2fbc89/attachment.html>


More information about the CMake mailing list