# Installing a list of headers dynamically generated at build time with names unknown at configure time

**URL:** https://discourse.cmake.org/t/installing-a-list-of-headers-dynamically-generated-at-build-time-with-names-unknown-at-configure-time/15327
**Category:** Code
**Created:** [November 19, 2025, 3:48pm UTC](https://discourse.cmake.org/t/installing-a-list-of-headers-dynamically-generated-at-build-time-with-names-unknown-at-configure-time/15327 "2025-11-19T15:48:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![alcroito](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alcroito/32/186_2.png) [@alcroito](https://discourse.cmake.org/u/alcroito)
#### Post date: [November 19, 2025, 3:48pm UTC](https://discourse.cmake.org/t/installing-a-list-of-headers-dynamically-generated-at-build-time-with-names-unknown-at-configure-time/15327/1 "2025-11-19T15:48:43Z")

</div>

Hi,

I’m wondering what’s today’s best way to install a list of generated header files that are not known at configure time.

I have an `add_custom_command` that runs a custom tool to parse a yaml file and then generate a list of headers and cpp sources, to ultimately build a shared library.

The names of the sources and headers is not known at configure time, so I can’t do `target_sources(library PRIVATE [unknown sources here])`.

That’s why the tool also generates a single `.h` and `.cpp` file pair out of the generated headers, and then the cmake code does `target_sources(library PRIVATE amalgamated.h amalgamated.cpp)`

This follows the advice given at [Dynamic Generation of source files at configure/build time - #6 by ben.boeckel](https://discourse.cmake.org/t/dynamic-generation-of-source-files-at-configure-build-time/10749/6)

This builds the library successfully, but now I need to install both the prebuilt library, and the original separate header files.

I can’t use `target_sources(library PRIVATE FILE_SET public_headers TYPE HEADERS FILES ...)` + `install(TARGETS library FILE_SET public_headers)` because that requires knowing the names of the header files at configure time, which i don’t have.

The best i can think of, is have the tool place the headers into a known directory, and then use `install(DIRECTORY)`.

Is there a better way to achieve this? Perhaps by fundamentally changing something in the project?

Unfortunately I can’t parse the yaml (and it’s included sub-yamls) at configure time to derive the headers names, so that idea doesn’t work.

I also can’t run the tool at configure time to extract the names, it takes too long, and the tool is built by the project itself.
