cmake/Help/command/build_command.rst

52 lines
1.8 KiB
ReStructuredText
Raw Normal View History

2014-08-03 19:52:23 +02:00
build_command
-------------
Get a command line to build the current project.
This is mainly intended for internal use by the :module:`CTest` module.
.. code-block:: cmake
build_command(<variable>
[CONFIGURATION <config>]
2021-09-14 00:13:48 +02:00
[PARALLEL_LEVEL <parallel>]
2014-08-03 19:52:23 +02:00
[TARGET <target>]
[PROJECT_NAME <projname>] # legacy, causes warning
)
Sets the given ``<variable>`` to a command-line string of the form::
2021-09-14 00:13:48 +02:00
<cmake> --build . [--config <config>] [--parallel <parallel>] [--target <target>...] [-- -i]
2014-08-03 19:52:23 +02:00
where ``<cmake>`` is the location of the :manual:`cmake(1)` command-line
2021-09-14 00:13:48 +02:00
tool, and ``<config>``, ``<parallel>`` and ``<target>`` are the values
provided to the ``CONFIGURATION``, ``PARALLEL_LEVEL`` and ``TARGET``
options, if any. The trailing ``-- -i`` option is added for
:ref:`Makefile Generators` if policy :policy:`CMP0061` is not set to
``NEW``.
2014-08-03 19:52:23 +02:00
When invoked, this ``cmake --build`` command line will launch the
underlying build system tool.
2021-09-14 00:13:48 +02:00
.. versionadded:: 3.21
The ``PARALLEL_LEVEL`` argument can be used to set the ``--parallel``
flag.
2014-08-03 19:52:23 +02:00
.. code-block:: cmake
build_command(<cachevariable> <makecommand>)
This second signature is deprecated, but still available for backwards
compatibility. Use the first signature instead.
It sets the given ``<cachevariable>`` to a command-line string as
2015-08-17 11:37:30 +02:00
above but without the ``--target`` option.
2014-08-03 19:52:23 +02:00
The ``<makecommand>`` is ignored but should be the full path to
2016-07-09 11:21:54 +02:00
devenv, nmake, make or one of the end user build tools
2014-08-03 19:52:23 +02:00
for legacy invocations.
.. note::
In CMake versions prior to 3.0 this command returned a command
line that directly invokes the native build tool for the current
generator. Their implementation of the ``PROJECT_NAME`` option
had no useful effects, so CMake now warns on use of the option.