# Installing headers the modern way, regurgitated and revisited

**URL:** <https://discourse.cmake.org/t/installing-headers-the-modern-way-regurgitated-and-revisited/3238>\
**Category:** Code\
**Created:** [April 29, 2021, 8:29pm UTC](https://discourse.cmake.org/t/installing-headers-the-modern-way-regurgitated-and-revisited/3238 "2021-04-29T20:29:15Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mherok](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mherok/32/3310_2.png) [@mherok](https://discourse.cmake.org/u/mherok)\
**Post date:** [April 5, 2023, 4:19am UTC](https://discourse.cmake.org/t/installing-headers-the-modern-way-regurgitated-and-revisited/3238/3 "2023-04-05T04:19:57Z")

</div>

From CMake 3.23 version `target_source` contain [FILE\_SET](https://cmake.org/cmake/help/latest/command/target_sources.html#file-sets) option. Now you can define your headers in one place and automatically use them on an install operation. Even `include_directories` it’s not any more necessary. This gives more improvements and can be used for modules export, for details read the documentation, [install](https://cmake.org/cmake/help/latest/command/install.html#targets) section also.

The above example can be written like this:

```auto
target_sources(
  mylib
  PUBLIC
    FILE_SET public-headers
    TYPE HEADERS
    FILES
      myfirstpublicheader.h
      mysecondpublicheader.h
)

install(TARGETS mylib FILE_SET public-headers)

```

---

_[View the full topic](https://discourse.cmake.org/t/installing-headers-the-modern-way-regurgitated-and-revisited/3238)._
