I often hit this, particularly with header-only INTERFACE libraries where I
just want to pick up their defines/include paths, and then CMake ends up
treating the target_link_libraries(PRIVATE as public anyway). So it would
definitely be helpful to have a warning that this doesn’t do what you’d expect,
and maybe a pointer to $ which seems to be the
only way to actually have a private (not listed in the exported
dependency while building a static library.
From: CMake [mailto:cmake-boun...@cmake.org] On Behalf Of Marc CHEVRIER
Sent: Friday, January 25, 2019 8:54 AM
To: Cmake Mailing List ; Andrew Bell
Subject: Re: [CMake] Static Libraries and target_link_libraries
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
mailto:andrew.bell...@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...@gmail.com<mailto:andrew.bell...@gmail.com>
--
Powered by www.kitware.com<http://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
--
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