mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-20 14:10:27 -06:00
Merge topic 'separate_arguments-program'
d832c1cc7dseparate_arguments: add option PROGRAMf4c21d4953separate_arguments: refactoring Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5253
This commit is contained in:
@@ -44,12 +44,6 @@ Paths are returned with forward slashes and have no trailing slashes. If the
|
||||
optional ``CACHE`` argument is specified, the result variable is added to the
|
||||
cache.
|
||||
|
||||
.. note::
|
||||
|
||||
All previous sub-commands has been superseded by
|
||||
:command:`cmake_path` command, except ``REALPATH`` now offered by
|
||||
:ref:`file(REAL_PATH) <REAL_PATH>` command.
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
get_filename_component(<var> <FileName> PROGRAM [PROGRAM_ARGS <arg_var>] [CACHE])
|
||||
@@ -59,3 +53,9 @@ left as a full path. If ``PROGRAM_ARGS`` is present with ``PROGRAM``, then
|
||||
any command-line arguments present in the ``<FileName>`` string are split
|
||||
from the program name and stored in ``<arg_var>``. This is used to
|
||||
separate a program name from its arguments in a command line string.
|
||||
|
||||
.. note::
|
||||
|
||||
This command been superseded by :command:`cmake_path` command, except
|
||||
``REALPATH`` now offered by :ref:`file(REAL_PATH) <REAL_PATH>` command and
|
||||
``PROGRAM`` now available in :command:`separate_arguments(PROGRAM)` command.
|
||||
|
||||
@@ -5,7 +5,7 @@ Parse command-line arguments into a semicolon-separated list.
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
separate_arguments(<variable> <mode> <args>)
|
||||
separate_arguments(<variable> <mode> [PROGRAM [SEPARATE_ARGS]] <args>)
|
||||
|
||||
Parses a space-separated string ``<args>`` into a list of items,
|
||||
and stores this list in semicolon-separated standard form in ``<variable>``.
|
||||
@@ -35,6 +35,36 @@ be one of the following keywords:
|
||||
Proceeds as in ``WINDOWS_COMMAND`` mode if the host system is Windows.
|
||||
Otherwise proceeds as in ``UNIX_COMMAND`` mode.
|
||||
|
||||
``PROGRAM``
|
||||
The first item in ``<args>`` is assumed to be an executable and will be
|
||||
search in the system search path or left as a full path. If not found,
|
||||
``<variable>`` will be empty. Otherwise, ``<variable>`` is a list of 2
|
||||
elements:
|
||||
|
||||
0. Absolute path of the program
|
||||
1. Any command-line arguments present in ``<args>`` as a string
|
||||
|
||||
For example:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
separate_arguments (out UNIX_COMMAND PROGRAM "cc -c main.c")
|
||||
|
||||
* First element of the list: ``/path/to/cc``
|
||||
* Second element of the list: ``" -c main.c"``
|
||||
|
||||
``SEPARATE_ARGS``
|
||||
When this sub-option of ``PROGRAM`` option is specified, command-line
|
||||
arguments will be split as well and stored in ``<variable>``.
|
||||
|
||||
For example:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
separate_arguments (out UNIX_COMMAND PROGRAM SEPARATE_ARGS "cc -c main.c")
|
||||
|
||||
The contents of ``out`` will be: ``/path/to/cc;-c;main.c``
|
||||
|
||||
.. _`Parsing C Command-Line Arguments`: https://msdn.microsoft.com/library/a1y7w461.aspx
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
Reference in New Issue
Block a user