[CMake] extending clean for Ninja

Torsten Robitzki Torsten at Robitzki.de
Thu Dec 6 12:03:25 EST 2018


Hi,
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)?

Best regards,

Torsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <https://cmake.org/pipermail/cmake/attachments/20181206/998f50e1/attachment.sig>


More information about the CMake mailing list