[CMake] Static Libraries and target_link_libraries

Marc CHEVRIER marc.chevrier at gmail.com
Fri Jan 25 09:54:28 EST 2019


It is quite inexact because a target can store many information like include directories or preprocessor definitions for example (through properties like INCLUDE_DIRECTORIES or COMPILE_DEFINITIONS).

So it make sense to enable to specify link libraries to a static library using PRIVATE or PUBLIC to ensure various settings are propagated to the static library compilation step.
Le 25 janv. 2019 à 15:46 +0100, Andrew Bell <andrew.bell.ia at gmail.com>, a écrit :
>
> When creating a static library, you can still use the function "target_link_libraries" even though the static library is never linked, as such.  What you're doing is creating a dependency record for cmake so that target_link_libraries of a static library are included in a link of some other target which depends on the static library.  What seems confusing is that target_link_libraries accepts the keywords PUBLIC and PRIVATE as well as INTERFACE when used with a static library, since only INTERFACE really makes sense in this context.
>
> Would it be beneficial to issue a warning when someone uses PUBLIC or PRIVATE with target_link_libraries on a static library to make it clear that they may not be understanding what's going on?
>
> --
> Andrew Bell
> andrew.bell.ia at gmail.com
> --
>
> 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:
> https://cmake.org/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190125/5322c5bc/attachment.html>


More information about the CMake mailing list