Is it possible to retrieve the list of public headers when using target_sources(... FILE_SET HEADERS ...)?

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:

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!

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})

There are the HEADER_SET_<NAME> properties you can use to get these paths.

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