1CMP0116 2------- 3 4.. versionadded:: 3.20 5 6Ninja generators transform ``DEPFILE`` s from :command:`add_custom_command`. 7 8In CMake 3.19 and below, files given to the ``DEPFILE`` argument of 9:command:`add_custom_command` were passed directly to Ninja's ``depfile`` 10variable without any path resolution. This meant that if 11:command:`add_custom_command` was called from a subdirectory (created by 12:command:`add_subdirectory`), the ``DEPFILE`` argument would have to be either 13an absolute path or a path relative to :variable:`CMAKE_BINARY_DIR`, rather 14than :variable:`CMAKE_CURRENT_BINARY_DIR`. In addition, no transformation was 15done on the file listed in ``DEPFILE``, which meant that the paths within the 16``DEPFILE`` had the same restrictions. 17 18Starting with CMake 3.20, the ``DEPFILE`` argument is relative to 19:variable:`CMAKE_CURRENT_BINARY_DIR` (unless it is absolute), and the paths in 20the ``DEPFILE`` are also relative to :variable:`CMAKE_CURRENT_BINARY_DIR`. 21CMake automatically transforms the paths in the ``DEPFILE`` (unless they are 22absolute) after the custom command is run. The file listed in ``DEPFILE`` is 23not modified in any way. Instead, CMake writes the transformation to its own 24internal file, and passes this internal file to Ninja's ``depfile`` variable. 25This transformation happens regardless of whether or not ``DEPFILE`` is 26relative, and regardless of whether or not :command:`add_custom_command` is 27called from a subdirectory. 28 29The ``OLD`` behavior for this policy is to pass the ``DEPFILE`` to Ninja 30unaltered. The ``NEW`` behavior for this policy is to transform the ``DEPFILE`` 31after running the custom command. The status of ``CMP0116`` is recorded at the 32time of the custom command's creation, and you can have custom commands in the 33same directory with different values for ``CMP0116`` by setting the policy 34before each custom command. 35 36This policy was introduced in CMake version 3.20. Unlike most policies, 37CMake version |release| does *not* warn by default when this policy is not set 38(unless ``DEPFILE`` is used in a subdirectory) and simply uses ``OLD`` 39behavior. See documentation of the 40:variable:`CMAKE_POLICY_WARNING_CMP0116 <CMAKE_POLICY_WARNING_CMP<NNNN>>` 41variable to control the warning. 42