I’m no expert in build.ninja’s syntax, but it seems, that the generator replaces my absolute path by an invalid relative one.
The documentation to add_custom_command also mentions restrictions when using genexps in OUTPUT. But 1) it seems to be related to target-specific ones and 2) in my case the genexp forms only a part of the whole output path, so it should not be cut off completely.
Up to now, I wasn’t able to reduce the problem to something minimalistic.The custom commands and targets are generated in code from complex transformations of variables in a whole hierarchy of cmake projects.
As I said, I create custom commands/targets programmatically. To do this, I need to precompute the dependencies for both by recording the respective mix of files and targets in cmake lists. For some reason, I thought that these lists had to be converted to some string with spaces as separators (I even handled the spaces inside the paths without thinking twice). This is wrong, of course, since DEPENDS simply expects the arguments to be a cmake list. Debug messages look quite innocent, of course.
The hard part was that the error occurred after configuration and before build (during build system generation) and was hard to nail down.