file(RENAME): Add option to not replace existing path

Add a `NO_REPLACE` option that prevents overwriting `<newname>`
if it exists.
This commit is contained in:
Brad King
2021-03-04 08:13:16 -05:00
parent 3600c6cd8c
commit 9bf40d8027
10 changed files with 64 additions and 5 deletions
+7 -1
View File
@@ -666,7 +666,8 @@ Examples of recursive globbing include::
.. code-block:: cmake
file(RENAME <oldname> <newname>
[RESULT <result>])
[RESULT <result>]
[NO_REPLACE])
Move a file or directory within a filesystem from ``<oldname>`` to
``<newname>``, replacing the destination atomically.
@@ -677,6 +678,11 @@ The options are:
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.
``NO_REPLACE``
If the ``<newname>`` path already exists, do not replace it.
If ``RESULT <result>`` is used, the result variable will be
set to ``NO_REPLACE``. Otherwise, an error is emitted.
.. _REMOVE:
.. _REMOVE_RECURSE: