# Is it possible to retrieve the list of public headers when using target\_sources(... FILE\_SET HEADERS ...)?

**URL:** https://discourse.cmake.org/t/is-it-possible-to-retrieve-the-list-of-public-headers-when-using-target-sources-file-set-headers/5757
**Category:** Usage
**Created:** [May 30, 2022, 9:57am UTC](https://discourse.cmake.org/t/is-it-possible-to-retrieve-the-list-of-public-headers-when-using-target-sources-file-set-headers/5757 "2022-05-30T09:57:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![raygerlabs](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/4af34b/32.png) [@raygerlabs](https://discourse.cmake.org/u/raygerlabs)
#### Post date: [May 30, 2022, 9:57am UTC](https://discourse.cmake.org/t/is-it-possible-to-retrieve-the-list-of-public-headers-when-using-target-sources-file-set-headers/5757/1 "2022-05-30T09:57:41Z")

</div>

Dear all,

I find the new features in Cmake 3.23 very handy and useful so far! I have just one minor issue right now. If I specify my source and header files with target\_sources(…) I can retrieve the .cpp files simply by calling get\_target\_property(var target SOURCES). Unfortunately if I do the same with the header files I receive an empty list. I tried all kinds of different approaches. For example:

```auto
get_target_property(var target HEADERS)
get_target_property(var target INTERFACE_SOURCES) # specified header files with INTERFACE specifier

```

My question is how am I supposed to treat such a case? I shared a piece of code I am having trouble with below.

Thank you in advance for your kind support!

```auto
target_sources(foo
  PRIVATE
    foo.cpp
  PUBLIC INTERFACE
    FILE_SET HEADERS
      BASE_DIRS
        ${CMAKE_SOURCE_DIR}
      FILES
        ../include/foo.hpp
        ../include/details/config.hpp
)
...
get_target_property(SOURCES foo SOURCES)
get_target_property(HEADERS foo INTERFACE_SOURCES)
source_group(TREE "${CMAKE_SOURCE_DIR}" FILES ${SOURCES} ${HEADERS})

```

---

<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: [May 30, 2022, 12:40pm UTC](https://discourse.cmake.org/t/is-it-possible-to-retrieve-the-list-of-public-headers-when-using-target-sources-file-set-headers/5757/2 "2022-05-30T12:40:25Z")

</div>

There are the [`HEADER_SET_<NAME>`](https://cmake.org/cmake/help/latest/prop_tgt/HEADER_SET_NAME.html) properties you can use to get these paths.

---

<div class="post-metadata">

### Author: ![raygerlabs](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/4af34b/32.png) [@raygerlabs](https://discourse.cmake.org/u/raygerlabs)
#### Post date: [May 31, 2022, 11:45am UTC](https://discourse.cmake.org/t/is-it-possible-to-retrieve-the-list-of-public-headers-when-using-target-sources-file-set-headers/5757/3 "2022-05-31T11:45:32Z")

</div>

Thank you very much for the quick response. It is working OK.
