summaryrefslogtreecommitdiffstats
path: root/Help/command
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2021-03-04 16:50:10 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2021-03-10 15:43:18 (GMT)
commit088444211e942a3587f4af5ef76c3654f2562364 (patch)
treefa5bd94beead2050d900e7c2341dc27899b2733e /Help/command
parent100016e9cb31aad7b642a9733409c7294cd6652f (diff)
downloadCMake-088444211e942a3587f4af5ef76c3654f2562364.zip
CMake-088444211e942a3587f4af5ef76c3654f2562364.tar.gz
CMake-088444211e942a3587f4af5ef76c3654f2562364.tar.bz2
file: add `COPY_FILE` subcommand
The `file(COPY)` subcommand is overloaded and busy for such a simple operation. Instead, make a simpler subcommand with error handling support.
Diffstat (limited to 'Help/command')
-rw-r--r--Help/command/file.rst23
1 files changed, 23 insertions, 0 deletions
diff --git a/Help/command/file.rst b/Help/command/file.rst
index 9cde90c..445a408 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -39,6 +39,7 @@ Synopsis
`Filesystem`_
file({`GLOB`_ | `GLOB_RECURSE`_} <out-var> [...] [<globbing-expr>...])
file(`RENAME`_ <oldname> <newname> [...])
+ file(`COPY_FILE`_ <oldname> <newname> [...])
file({`REMOVE`_ | `REMOVE_RECURSE`_ } [<files>...])
file(`MAKE_DIRECTORY`_ [<dir>...])
file({`COPY`_ | `INSTALL`_} <file>... DESTINATION <dir> [...])
@@ -683,6 +684,28 @@ The options are:
If ``RESULT <result>`` is used, the result variable will be
set to ``NO_REPLACE``. Otherwise, an error is emitted.
+.. _COPY_FILE:
+
+.. code-block:: cmake
+
+ file(COPY_FILE <oldname> <newname>
+ [RESULT <result>]
+ [ONLY_IF_DIFFERENT])
+
+Copy a file from ``<oldname>`` to ``<newname>``. Directories are not
+supported. Symlinks are ignored and ``<oldfile>``'s content is read and
+written to ``<newname>`` as a new file.
+
+The options are:
+
+``RESULT <result>``
+ Set ``<result>`` variable to ``0`` on success or an error message otherwise.
+ If ``RESULT`` is not specified and the operation fails, an error is emitted.
+
+``ONLY_IF_DIFFERENT``
+ If the ``<newname>`` path already exists, do not replace it if it is the
+ same as ``<oldname>``. Otherwise, an error is emitted.
+
.. _REMOVE:
.. _REMOVE_RECURSE: