we have some source file generators, that take a known list of input files and generate an „relatively“ unknown list of output files. The exact list of output files depend on the content of the input files. The „usual“ way to solve this seams to have an add_custom_target() call, and listing all output files as BYPRODUCTS, because then Ninja would know the output files as being targets and would delete them when asked to clean the project.
Assumed all output files would be in the same directory and that it would be safe to delete the entire directory, I though, I could add the directory name as BYPRODUCTS. Unfortunately this hack doesn’t work, because the OS function that Ninja uses to remove files does not delete not empty directories.
If I could use the very same generator to produce the list of output files, I could then add this list as BYPRODUCTS option to `add_custom_target()`. One problem still would remain: if I change one of the input files, so that the list of output files change, cmake would have to re-run.
Does someone of you have an idea, how to force cmake to re-run, if a certain list of files changed? Is there an easier way to archive what I want (to delete the output files when Ninja -t clean is called)?