# Difference between PUBLIC and INTERFACE is not stated

**URL:** https://discourse.cmake.org/t/difference-between-public-and-interface-is-not-stated/7926
**Category:** Site Feedback
**Created:** [April 18, 2023, 2:09pm UTC](https://discourse.cmake.org/t/difference-between-public-and-interface-is-not-stated/7926 "2023-04-18T14:09:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![studyingegret](https://discourse.cmake.org/user_avatar/discourse.cmake.org/studyingegret/32/3341_2.png) [@studyingegret](https://discourse.cmake.org/u/studyingegret)
#### Post date: [April 18, 2023, 2:09pm UTC](https://discourse.cmake.org/t/difference-between-public-and-interface-is-not-stated/7926/1 "2023-04-18T14:09:05Z")

</div>

Hello,

I read [`cmake-compile-features(7)`](https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html) and I couldn’t find text saying the difference between `PUBLIC` and `INTERFACE`. I think [Transitive Usage Requirements](https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#target-usage-requirements) should be linked here to clarify this.

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [April 18, 2023, 2:46pm UTC](https://discourse.cmake.org/t/difference-between-public-and-interface-is-not-stated/7926/2 "2023-04-18T14:46:36Z")

</div>

The docs for `target_compile_features` talk about this, and I feel like that’s the right place.

---

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [April 18, 2023, 3:58pm UTC](https://discourse.cmake.org/t/difference-between-public-and-interface-is-not-stated/7926/3 "2023-04-18T15:58:34Z")

</div>

> [@the usage of target\_include\_directories vs target\_link\_libraries](https://discourse.cmake.org/t/the-usage-of-target-include-directories-vs-target-link-libraries/7914/6):
>
> Hi IMHO, I partially agree for the executable part but not for the library one. First of all it does not depend on the shared/static status. Let say a lib A depends on a lib B. If the headers of A that may be included by an application that links A contains symbols from B then target\_link\_libraries(A PUBLIC B) otherwise target\_link\_libraries(A PRIVATE B) another situation may arise: B symbols are only present in A headers but are not used for A sources. then target\_link\_libraries(A INTERFA…

---

<div class="post-metadata">

### Author: ![studyingegret](https://discourse.cmake.org/user_avatar/discourse.cmake.org/studyingegret/32/3341_2.png) [@studyingegret](https://discourse.cmake.org/u/studyingegret)
#### Post date: [April 21, 2023, 10:26am UTC](https://discourse.cmake.org/t/difference-between-public-and-interface-is-not-stated/7926/4 "2023-04-21T10:26:53Z")

</div>

> [@fenrir](#):
>
> The docs for `target_compile_features` talk about this, and I feel like that’s the right place.

I agree it will be helpful to talk about it there in the section [“Compile Feature Requirements”](https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html#compile-feature-requirements), although that section is not mainly for it (?) and it would repeat with [“Transitive Usage Requirements”](https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#target-usage-requirements).

My understanding of `INTERFACE` is “you don’t need to use it, but it is needed when others use you”.

---

<div class="post-metadata">

### Author: ![studyingegret](https://discourse.cmake.org/user_avatar/discourse.cmake.org/studyingegret/32/3341_2.png) [@studyingegret](https://discourse.cmake.org/u/studyingegret)
#### Post date: [April 21, 2023, 10:32am UTC](https://discourse.cmake.org/t/difference-between-public-and-interface-is-not-stated/7926/5 "2023-04-21T10:32:10Z")

</div>

@adaldev So do you agree on explaining or linking it there? Could you give a clear answer?

---

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [April 21, 2023, 1:15pm UTC](https://discourse.cmake.org/t/difference-between-public-and-interface-is-not-stated/7926/6 "2023-04-21T13:15:42Z")

</div>

Is it what you needed?

> [@the usage of target\_include\_directories vs target\_link\_libraries](https://discourse.cmake.org/t/the-usage-of-target-include-directories-vs-target-link-libraries/7914/6):
>
> I sum up it in the following way (`for target_compile_definitions` and `target_link_libraries`):  
> `PRIVATE`: the target uses the definition/dependency only to be build, not its clients  
> `PUBLIC`: the target uses the definition/dependency when it is built, its clients also use it  
> `INTERFACE`: the target does not uses the definition/dependency when it is built, but its clients use it

it’s also the same for `target_compile_features` by the way (just replace _definition_ or _dependency_ by _feature_)
