[CMake] Difference between PRIVATE and PUBLIC with target_link_libraries

Patrick Boettcher patrick.boettcher at posteo.de
Thu May 12 10:26:49 EDT 2016


On Thu, 12 May 2016 09:20:10 -0500
iosif neitzke <iosif.neitzke+cmake at gmail.com> wrote:

> I'm sorry, I'm not sure I understand.  In your example, there is
> target_link_libraries(lib3 PUBLIC lib1).  It looks like lib2 has
> target_link_libraries(lib2 PRIVATE lib1).

Yes. That is correct.

When building the code for lib2 and lib3 the include-path of lib1 is
provided (as expected).

Then when building exe1 (links to lib2) and exe2 (links to lib3) the
lib1's include-path is present in both cases.

Whereas it should not be present with exe1, at least that is my
understanding.

--
Patrick.


More information about the CMake mailing list