# Install header only targets?

**URL:** https://discourse.cmake.org/t/install-header-only-targets/5147
**Category:** Code
**Created:** [March 2, 2022, 2:10pm UTC](https://discourse.cmake.org/t/install-header-only-targets/5147 "2022-03-02T14:10:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cmak](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/eb8c5e/32.png) [@cmak](https://discourse.cmake.org/u/cmak)
#### Post date: [March 2, 2022, 2:10pm UTC](https://discourse.cmake.org/t/install-header-only-targets/5147/1 "2022-03-02T14:10:13Z")

</div>

What is the correct way to install header only targets? Currently I’m doing something like this;

```cmake
install(
    DIRECTORY include/my_header_interface
    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

```

Trying to do `install(TARGETS my_header_interface)` simply fails. Why is that?

Setting target properties `PUBLIC_HEADER` and installing that seems very clumsy.

I would also like to install my target only, e.g. `ninja my_header_interface/install`, but `INTERFACE` targets are not seen in ninja.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 2, 2022, 2:34pm UTC](https://discourse.cmake.org/t/install-header-only-targets/5147/2 "2022-03-02T14:34:40Z")

</div>

> [@cmak](#):
>
> Trying to do `install(TARGETS my_header_interface)` simply fails. Why is that?

Is there an error message?

> [@cmak](#):
>
> I would also like to install my target only, e.g. `ninja my_header_interface/install`, but `INTERFACE` targets are not seen in ninja.

Install components are all that are provided generically for such things, sorry.
