[CMake] Private dependencies of static libraries exported as targets

Guillaume Dumont dumont.guillaume at gmail.com
Mon Aug 15 21:46:16 EDT 2016


If you export you targets using

install(EXPORT ...)

then the foo static library should contain a dependency to bar in its
INTERFACE_LINK libraries. If bar is an imported target your config file
should use find_dependency so that the bar imported target is resolved by
consuming CMake based packages. If bar is just the path to the binary than
the absolute path will be recorded in your export files and your foo
package will become non relocatable. As far as I know the PRIVATE keyword
should have no effect on transitive linking when foo is static and we call:

target_link_libraries(foo PRIVATE bar)

Hope this helps.


On Mon, Aug 15, 2016 at 9:32 PM, Ivan Shapovalov <intelfx at intelfx.name>
wrote:

> ks to a library `bar`, which is an implementation detail, i. e.
> clients of `foo` do not need to know that I use `bar`. Hence I make it
> a PRIVATE dependency (let's assume that authors of Bar also try to do
> modern CMake and pac
>




-- 
Guillaume Dumont
=========================
dumont.guillaume at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160815/1175360f/attachment.html>


More information about the CMake mailing list