Hi,

I will offer an alternative phrasing based on what makes me personally
understand this best. It might potentially be useful for the documentation
update you're planning.

`target_link_libraries(A B)` specifies that the code in A needs B to be
added to the produced binary when the binary is *linked*. However, static
libraries are not produced by linking, but by an archiver or librarian
tool. Therefore, B needs to be present for the actual linking step when
this happens further down the chain (when linking an executable or shared
library), regardless of the "privacy" of B in A.

Petr

On 18 April 2017 at 17:44, Eric Noulard <eric.noul...@gmail.com> wrote:

> 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.noul...@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
>
> --
>
> 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
>
-- 

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

Reply via email to