# Using PUBLIC FILE\_SET HEADERS with dependent targets

**URL:** https://discourse.cmake.org/t/using-public-file-set-headers-with-dependent-targets/10031
**Category:** Usage
**Created:** [February 8, 2024, 12:13am UTC](https://discourse.cmake.org/t/using-public-file-set-headers-with-dependent-targets/10031 "2024-02-08T00:13:21Z")
**Posts on this page:** 1
**Showing post:** 5

<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: [February 17, 2024, 1:00pm UTC](https://discourse.cmake.org/t/using-public-file-set-headers-with-dependent-targets/10031/5 "2024-02-17T13:00:03Z")

</div>

You may try it like this snippet:

```cmake
# ...
# Write spglib_export.h to the current binary directory
include(GenerateExportHeader)
generate_export_header(Spglib_symspg
	EXPORT_FILE_NAME spglib_export.h
	EXPORT_MACRO_NAME API_SPGLIB
)
configure_file(spglib.h spglib.h COPYONLY)

target_sources(Spglib_symspg
	PUBLIC
		FILE_SET HEADERS
		BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR}
		FILES
			${CMAKE_CURRENT_BINARY_DIR}/spglib_export.h
			${CMAKE_CURRENT_BINARY_DIR}/spglib.h
)
target_include_directories(Spglib_symspg
		PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
		PUBLIC
		"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
		"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
# ...

```

---

_[View the full topic](https://discourse.cmake.org/t/using-public-file-set-headers-with-dependent-targets/10031)._
