# target\_precompile\_headers(PRIVATE) in library project does not work when using library functions in an executable project..

**URL:** https://discourse.cmake.org/t/target-precompile-headers-private-in-library-project-does-not-work-when-using-library-functions-in-an-executable-project/15313
**Category:** Code
**Tags:** os:linux, comp:gcc, comp:clang, gen:ninja
**Created:** [November 16, 2025, 10:11pm UTC](https://discourse.cmake.org/t/target-precompile-headers-private-in-library-project-does-not-work-when-using-library-functions-in-an-executable-project/15313 "2025-11-16T22:11:02Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [November 17, 2025, 6:55pm UTC](https://discourse.cmake.org/t/target-precompile-headers-private-in-library-project-does-not-work-when-using-library-functions-in-an-executable-project/15313/2 "2025-11-17T18:55:40Z")

</div>

I have never use precompiled header and I would not do it.

How will you install only our public interface header only?

Use:

```cmake
target_sources(targetName
      <PRIVATE|PUBLIC|INTERFACE>
          FILE_SET setName
          [TYPE fileType]
          [BASE_DIRS dir1 [dir2...]]
          [FILES file1 [file2...]]
... )

```

Than your project will be much simpler and clear.

But perhaps this [Include directories for target\_precompile\_headers](https://discourse.cmake.org/t/include-directories-for-target-precompile-headers/2607) may help you.

---

_[View the full topic](https://discourse.cmake.org/t/target-precompile-headers-private-in-library-project-does-not-work-when-using-library-functions-in-an-executable-project/15313)._
