[CMake] Libraries for a Target and/or its Dependents

Tamás Kenéz tamas.kenez at gmail.com
Tue Sep 15 06:07:47 EDT 2015


I guess `Test` is also a static library. In that case this is the intended
behaviour.
Since `private_lib` is not compiled into `Test`'s object files, when you
link the consumer of `Test` you still need to pull in `private_lib`.

If `Test` were a shared lib then `private_lib` would not be listed.

Tamas

On Mon, Sep 14, 2015 at 12:10 PM, Wojciech Mamrak <wmamrak at gmail.com> wrote:

> Hello,
>
> The docs say [1]:
> "Libraries and targets following PRIVATE are linked to, but are not
> made part of the link interface."
>
> If so, why does this snippet:
>
> add_library(private_lib STATIC ...)
> add_library(public_lib STATIC ...)
>
> target_link_libraries(Test PRIVATE private_lib
>                                     PUBLIC public_lib)
> install(EXPORT ...)
>
> sets Test's imported target's properties with:
>
> IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "private_lib;public_lib"
>
> I thought BUILD_INTERFACE and INSTALL_INTERFACE generator expressions
> can solve this, but it turns out BUILD_INTERFACE is propagated, and
> INSTALL_INTERFACE is not, i.e.
>
> IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE
> "private_lib;public_lib;build_interface_lib"
>
> regards
>
> [1]
> http://www.cmake.org/cmake/help/v3.3/command/target_link_libraries.html#libraries-for-a-target-and-or-its-dependents
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150915/12e43d08/attachment.html>


More information about the CMake mailing list