[CMake] Private dependencies of static libraries exported as targets

Ivan Shapovalov intelfx at intelfx.name
Wed Aug 17 05:11:40 EDT 2016


On 2016-08-16 at 20:14 -0500, Nicholas Braden wrote:
> Ah, I misunderstood what you were asking about. It would be pretty
> weird if CMake didn't know that static libraries always need all
> their
> dependencies linked regardless of privacy, but I agree it should at
> least be mentioned somewhere. My bad.
> 
> As for include path bloat, I cannot replicate this in my test project
> - CMake will link all the dependencies as required but will NOT
> violate "PRIVATE" for other things like include directories. Could
> you
> give an example where you are seeing a static library's private
> dependency's include path being added when linking the static
> library?

Please take a look at https://github.com/intelfx/cmake-demo. This is a
sample dependency chain of two libraries and one executable (client ->
foo -> bar), both libraries are found and linked as IMPORTED targets. 
The client is built with VERBOSE=1 -- notice the compiler command
lines.

On my system it says (pretty self-explanatory):

/usr/bin/c++    -isystem /home/intelfx/devel/__auxiliary/experiments/cmake-static-transitive/prefix/foo/include -isystem /home/intelfx/devel/__auxiliary/experiments/cmake-static-transitive/prefix/bar/include   -o CMakeFiles/client.dir/src/
main.cpp.o -c /home/intelfx/devel/__auxiliary/experiments/cmake-static-transitive/client/src/main.cpp

-- 
Ivan Shapovalov / intelfx /
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160817/df2e32d5/attachment-0001.sig>


More information about the CMake mailing list