DEPFILE with Makefile generators

The DEPFILE argument of add_custom_command expects a file containing dependencies in the following format (format compatible with what gcc compiler generates for dependencies):

<target> : <dependency>+

<target> and <dependency> must be absolute paths or paths relative to CMAKE_CURRENT_BINARY_DIR. Backslash can be used to specify dependencies on multiple lines:

<target> : <dependency1> \
<dependency2>

This format is supported regardless of the generator used. CMake parse this dependency file, paths are normalized (and reformatted, depending of build tool used: nmake requires a different format than GNU Make) and, in case of Make generators, dependencies are aggregated in various files compiler_depend.make.

So, the depfile specified in add_custom_command() is never read by build tool, and it is an error to inject any make tool construct (like $(error...)).