file: Change REMOVE to ignore empty names

Previously code like

    file(REMOVE_RECURSE "${accidentally_missing_variable}")

treated the empty string as a relative path with respect to the
current directory and removed its contents.  Change this behavior
to ignore the empty string with a warning instead.

Normally such behavior changes are done with a policy, but in this case
such code is likely a real bug in project code that can delete data.

Fixes: #19274
This commit is contained in:
Brad King
2019-05-21 09:20:01 -04:00
parent 1db0edb2a6
commit a1eb03569d
6 changed files with 29 additions and 1 deletions

View File

@@ -292,7 +292,8 @@ Move a file or directory within a filesystem from ``<oldname>`` to
Remove the given files. The ``REMOVE_RECURSE`` mode will remove the given
files and directories, also non-empty directories. No error is emitted if a
given file does not exist.
given file does not exist. Relative input paths are evaluated with respect
to the current source directory. Empty input paths are ignored with a warning.
.. _MAKE_DIRECTORY: