summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-10-14 15:49:45 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-10-14 15:49:51 (GMT)
commitc5559597177eabd5620766e9dbc6f02a3b827ddb (patch)
tree8a5a7c2cef60393de936f7fbed63b99bb0139c3a /Help
parent609f2a14063c2bd7be416ac363257e616dce6ff2 (diff)
parent146e1e6ba14d964bf120635aca953cc76e5b2282 (diff)
downloadCMake-c5559597177eabd5620766e9dbc6f02a3b827ddb.zip
CMake-c5559597177eabd5620766e9dbc6f02a3b827ddb.tar.gz
CMake-c5559597177eabd5620766e9dbc6f02a3b827ddb.tar.bz2
Merge topic 'ninja-depfile-transformation'
146e1e6ba1 Ninja: Transform DEPFILEs with policy CMP0116 596439b1bb cmCustomCommandGenerator: Add option to transform depfile b2c14bc774 cmake -E: Add cmake_transform_depfile internal command 946adadd40 cmGccDepfileReader: Rework helper code Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5325
Diffstat (limited to 'Help')
-rw-r--r--Help/command/add_custom_command.rst5
-rw-r--r--Help/manual/cmake-policies.7.rst1
-rw-r--r--Help/policy/CMP0116.rst38
-rw-r--r--Help/release/dev/ninja-depfile-transformation.rst5
-rw-r--r--Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst2
5 files changed, 51 insertions, 0 deletions
diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index 231f9da..a28b0b1 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -239,6 +239,11 @@ The options are:
command itself.
Using ``DEPFILE`` with other generators than Ninja is an error.
+ If the ``DEPFILE`` argument is relative, it should be relative to
+ :variable:`CMAKE_CURRENT_BINARY_DIR`, and any relative paths inside the
+ ``DEPFILE`` should also be relative to :variable:`CMAKE_CURRENT_BINARY_DIR`
+ (see policy :policy:`CMP0116`.)
+
Build Events
^^^^^^^^^^^^
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 0836883..886fe80 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -57,6 +57,7 @@ Policies Introduced by CMake 3.20
.. toctree::
:maxdepth: 1
+ CMP0116: Ninja generators transform DEPFILEs from add_custom_command(). </policy/CMP0116>
CMP0115: Source file extensions must be explicit. </policy/CMP0115>
Policies Introduced by CMake 3.19
diff --git a/Help/policy/CMP0116.rst b/Help/policy/CMP0116.rst
new file mode 100644
index 0000000..25a14c4
--- /dev/null
+++ b/Help/policy/CMP0116.rst
@@ -0,0 +1,38 @@
+CMP0116
+-------
+
+.. versionadded:: 3.20
+
+Ninja generators transform ``DEPFILE`` s from :command:`add_custom_command`.
+
+In CMake 3.19 and below, files given to the ``DEPFILE`` argument of
+:command:`add_custom_command` were passed directly to Ninja's ``depfile``
+variable without any path resolution. This meant that if
+:command:`add_custom_command` was called from a subdirectory (created by
+:command:`add_subdirectory`), the ``DEPFILE`` argument would have to be either
+an absolute path or a path relative to :variable:`CMAKE_BINARY_DIR`, rather
+than :variable:`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
+:variable:`CMAKE_CURRENT_BINARY_DIR` (unless it is absolute), and the paths in
+the ``DEPFILE`` are also relative to :variable:`CMAKE_CURRENT_BINARY_DIR`.
+CMake automatically transforms the paths in the ``DEPFILE`` (unless they are
+absolute) after the custom command is run. The file listed in ``DEPFILE`` is
+not modified in any way. Instead, CMake writes the transformation to its own
+internal file, and passes this internal file to Ninja's ``depfile`` variable.
+This transformation happens regardless of whether or not ``DEPFILE`` is
+relative, and regardless of whether or not :command:`add_custom_command` is
+called from a subdirectory.
+
+The ``OLD`` behavior for this policy is to pass the ``DEPFILE`` to Ninja
+unaltered. The ``NEW`` behavior for this policy is to transform the ``DEPFILE``
+after running the custom command.
+
+This policy was introduced in CMake version 3.20. Unlike most policies,
+CMake version |release| does *not* warn by default when this policy is not set
+(unless ``DEPFILE`` is used in a subdirectory) and simply uses ``OLD``
+behavior. See documentation of the
+:variable:`CMAKE_POLICY_WARNING_CMP0116 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
+variable to control the warning.
diff --git a/Help/release/dev/ninja-depfile-transformation.rst b/Help/release/dev/ninja-depfile-transformation.rst
new file mode 100644
index 0000000..edf7f58
--- /dev/null
+++ b/Help/release/dev/ninja-depfile-transformation.rst
@@ -0,0 +1,5 @@
+ninja-depfile-transformation
+----------------------------
+
+* Ninja generators now transform ``DEPFILE`` s from
+ :command:`add_custom_command`. See policy :policy:`CMP0116` for details.
diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
index d35595a..9f68741 100644
--- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
+++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
@@ -27,6 +27,8 @@ warn by default:
policy :policy:`CMP0102`.
* ``CMAKE_POLICY_WARNING_CMP0112`` controls the warning for
policy :policy:`CMP0112`.
+* ``CMAKE_POLICY_WARNING_CMP0116`` controls the warning for
+ policy :policy:`CMP0116`.
This variable should not be set by a project in CMake code. Project
developers running CMake may set this variable in their cache to