From 0f5a9f7934913935d632fc596ba1b585aa10fa29 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Sat, 16 Feb 2019 19:32:52 +1100 Subject: Help: Clarify and improve readability of link-related file subcommands --- Help/command/file.rst | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Help/command/file.rst b/Help/command/file.rst index db4d6fc..465e567 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -26,8 +26,8 @@ Synopsis file(`MAKE_DIRECTORY`_ [...]) file({`COPY`_ | `INSTALL`_} ... DESTINATION [...]) file(`SIZE`_ ) - file(`READ_SYMLINK`_ ) - file(`CREATE_LINK`_ [...]) + file(`READ_SYMLINK`_ ) + file(`CREATE_LINK`_ [...]) `Path Conversion`_ file(`RELATIVE_PATH`_ ) @@ -350,22 +350,22 @@ pointing to a file and is readable. .. code-block:: cmake - file(READ_SYMLINK ) + file(READ_SYMLINK ) -Read the symlink at ```` and put the result in ````. -Requires that ```` is a valid path pointing to a symlink. If -```` does not exist, or is not a symlink, an error is thrown. +This subcommand queries the symlink ```` and stores the path it +points to in the result ````. If ```` does not exist or +is not a symlink, CMake issues a fatal error. 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: +a relative path. The following is an example of how to ensure that an +absolute path is obtained: .. code-block:: cmake - set(filename "/path/to/foo.sym") - file(READ_SYMLINK "${filename}" result) + set(linkname "/path/to/foo.sym") + file(READ_SYMLINK "${linkname}" result) if(NOT IS_ABSOLUTE "${result}") - get_filename_component(dir "${filename}" DIRECTORY) + get_filename_component(dir "${linkname}" DIRECTORY) set(result "${dir}/${result}") endif() @@ -373,23 +373,23 @@ could do something like this: .. code-block:: cmake - file(CREATE_LINK + file(CREATE_LINK [RESULT ] [COPY_ON_ERROR] [SYMBOLIC]) -Create a link to ```` at ````. +Create a link ```` that points to ````. +It will be a hard link by default, but providing the ``SYMBOLIC`` option +results in a symbolic link instead. Hard links require that ``original`` +exists and is a file, not a directory. If ```` already exists, +it will be overwritten. -It is a hard link by default. This can be changed to symbolic links by -using ``SYMBOLIC``. The original file needs to exist for hard links. - -The ```` variable, if specified, gets the status of the operation. -It is set to ``0`` in case of success. Otherwise, it contains the error -generated. In case of failures, if ``RESULT`` is not specified, a fatal error -is emitted. +The ```` variable, if specified, receives the status of the operation. +It is set to ``0`` upon success or an error message otherwise. If ``RESULT`` +is not specified and the operation fails, a fatal error is emitted. Specifying ``COPY_ON_ERROR`` enables copying the file as a fallback if -creating the link fails. - -Overwrites the ```` if it exists. +creating the link fails. It can be useful for handling situations such as +```` and ```` being on different drives or mount points, +which would make them unable to support a hard link. Path Conversion ^^^^^^^^^^^^^^^ -- cgit v0.12