summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-12-10 13:21:33 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-12-10 13:21:40 (GMT)
commit0bfe96a8c35aae2744efad664444ac5a963d74d3 (patch)
tree01274134ad4e168667e9deff248e77cc619459e6 /Help
parente1db7aac307e85154c1abd91afbdf61b65780caf (diff)
parent31840e363f61c10770a3d22467396c05e7d3d422 (diff)
downloadCMake-0bfe96a8c35aae2744efad664444ac5a963d74d3.zip
CMake-0bfe96a8c35aae2744efad664444ac5a963d74d3.tar.gz
CMake-0bfe96a8c35aae2744efad664444ac5a963d74d3.tar.bz2
Merge topic 'file-read_symlink'
31840e363f file: Fix formatting of error in SIZE sub-command 98a39be6cf file: Add READ_SYMLINK sub-command Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2705
Diffstat (limited to 'Help')
-rw-r--r--Help/command/file.rst24
-rw-r--r--Help/release/dev/file-read_symlink.rst5
2 files changed, 29 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
^^^^^^^^^^^^^^^
diff --git a/Help/release/dev/file-read_symlink.rst b/Help/release/dev/file-read_symlink.rst
new file mode 100644
index 0000000..718802e
--- /dev/null
+++ b/Help/release/dev/file-read_symlink.rst
@@ -0,0 +1,5 @@
+file-read_symlink
+-----------------
+
+* The :command:`file` command learned a new sub-command, ``READ_SYMLINK``,
+ which can be used to determine the path that a symlink points to.