New in version 3.20.
Ninja generators transform
DEPFILE s from
In CMake 3.19 and below, files given to the
DEPFILE argument of
add_custom_command() were passed directly to Ninja's
variable without any path resolution. This meant that if
add_custom_command() was called from a subdirectory (created by
DEPFILE argument would have to be either
an absolute path or a path relative to
CMAKE_CURRENT_BINARY_DIR. In addition, no transformation was
done on the file listed in
DEPFILE, which meant that the paths within the
DEPFILE had the same restrictions.
Starting with CMake 3.20, the
DEPFILE argument is relative to
CMAKE_CURRENT_BINARY_DIR (unless it is absolute), and the paths in
DEPFILE are also relative to
CMake automatically transforms the paths in the
DEPFILE (unless they are
absolute) after the custom command is run. The file listed in
not modified in any way. Instead, CMake writes the transformation to its own
internal file, and passes this internal file to Ninja's
This transformation happens regardless of whether or not
relative, and regardless of whether or not
called from a subdirectory.
OLD behavior for this policy is to pass the
DEPFILE to Ninja
NEW behavior for this policy is to transform the
after running the custom command. The status of
CMP0116 is recorded at the
time of the custom command's creation, and you can have custom commands in the
same directory with different values for
CMP0116 by setting the policy
before each custom command.
This policy was introduced in CMake version 3.20. Unlike most policies,
CMake version 3.21.7 does not warn by default when this policy is not set
DEPFILE is used in a subdirectory) and simply uses
behavior. See documentation of the
variable to control the warning.