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
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.