[CMake] Difference between PRIVATE and PUBLIC with target_link_libraries

iosif neitzke iosif.neitzke+cmake at gmail.com
Thu May 12 10:04:10 EDT 2016


target_include_directories(lib1 INTERFACE /tmp) means /tmp is
propagated with lib1, but not used to build lib1.

"The INTERFACE, PUBLIC and PRIVATE keywords are required to specify
the scope of the following arguments. PRIVATE and PUBLIC items will
populate the INCLUDE_DIRECTORIES property of <target>. PUBLIC and
INTERFACE items will populate the INTERFACE_INCLUDE_DIRECTORIES
property of <target>."

https://cmake.org/cmake/help/v3.5/command/target_include_directories.html

On Thu, May 12, 2016 at 8:59 AM, Patrick Boettcher
<patrick.boettcher at posteo.de> wrote:
> On Thu, 12 May 2016 08:47:33 -0500
> iosif neitzke <iosif.neitzke+cmake at gmail.com> wrote:
>
>> My reading of your examples:
>>
>> exe1 gets linked to lib2, and lib2/bin is included.  exe1 probably
>> won't link ultimately because lib2 may need symbols from lib1.
>> Depends on the structure of the C code between lib2 and lib1.   See
>> John Lakos for further information on that.
>
> It links - because it is a STATIC library - so propagated even though
> it's PRIVATE.
>
> My problem is just the include-dir of lib1 (/tmp) which should _not_ be
> propagated to exe1, but it is propagated.
>
> regards,
> --
> Patrick.


More information about the CMake mailing list