diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2018-12-05 20:27:08 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2018-12-06 15:11:51 (GMT) |
commit | 98a39be6cfb7b229ff78f7045c6d5bcd6b6c7509 (patch) | |
tree | 1f9810b45b6d79710d89457d2db530cf5be24613 /Help/command/file.rst | |
parent | 81bea69bd1d52977c3782d26560f34563394f487 (diff) | |
download | CMake-98a39be6cfb7b229ff78f7045c6d5bcd6b6c7509.zip CMake-98a39be6cfb7b229ff78f7045c6d5bcd6b6c7509.tar.gz CMake-98a39be6cfb7b229ff78f7045c6d5bcd6b6c7509.tar.bz2 |
file: Add READ_SYMLINK sub-command
Diffstat (limited to 'Help/command/file.rst')
-rw-r--r-- | Help/command/file.rst | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Help/command/file.rst b/Help/command/file.rst index 26a9ae2..6e2a6dd 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -26,6 +26,7 @@ Synopsis file(`MAKE_DIRECTORY`_ [<dir>...]) file({`COPY`_ | `INSTALL`_} <file>... DESTINATION <dir> [...]) file(`SIZE`_ <filename> <out-var>) + file(`READ_SYMLINK`_ <filename> <out-var>) `Path Conversion`_ file(`RELATIVE_PATH`_ <out-var> <directory> <file>) @@ -344,6 +345,29 @@ Determine the file size of the ``<filename>`` and put the result in ``<variable>`` variable. Requires that ``<filename>`` is a valid path pointing to a file and is readable. +.. _READ_SYMLINK: + +.. code-block:: cmake + + file(READ_SYMLINK <filename> <variable>) + +Read the symlink at ``<filename>`` and put the result in ``<variable>``. +Requires that ``<filename>`` is a valid path pointing to a symlink. If +``<filename>`` does not exist, or is not a symlink, an error is thrown. + +Note that this command returns the raw symlink path and does not resolve +relative symlinks. If you want to resolve the relative symlink yourself, you +could do something like this: + +.. code-block:: cmake + + set(filename "/path/to/foo.sym") + file(READ_SYMLINK "${filename}" result) + if(NOT IS_ABSOLUTE "${result}") + get_filename_component(dir "${filename}" DIRECTORY) + set(result "${dir}/${result}") + endif() + Path Conversion ^^^^^^^^^^^^^^^ |