build_command.rst 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. build_command
  2. -------------
  3. Get a command line to build the current project.
  4. This is mainly intended for internal use by the :module:`CTest` module.
  5. .. code-block:: cmake
  6. build_command(<variable>
  7. [CONFIGURATION <config>]
  8. [PARALLEL_LEVEL <parallel>]
  9. [TARGET <target>]
  10. [PROJECT_NAME <projname>] # legacy, causes warning
  11. )
  12. Sets the given ``<variable>`` to a command-line string of the form::
  13. <cmake> --build . [--config <config>] [--parallel <parallel>] [--target <target>...]
  14. where ``<cmake>`` is the location of the :manual:`cmake(1)` command-line
  15. tool, and ``<config>``, ``<parallel>`` and ``<target>`` are the values
  16. provided to the ``CONFIGURATION``, ``PARALLEL_LEVEL`` and ``TARGET``
  17. options, if any. In CMake versions prior to 4.0, a trailing ``-- -i``
  18. option was added for :ref:`Makefile Generators` if policy :policy:`CMP0061`
  19. was not set to ``NEW``.
  20. When invoked, this :option:`cmake --build` command line will launch the
  21. underlying build system tool.
  22. .. versionadded:: 3.21
  23. The ``PARALLEL_LEVEL`` argument can be used to set the
  24. :option:`--parallel <cmake--build --parallel>` flag.
  25. .. code-block:: cmake
  26. build_command(<cachevariable> <makecommand>)
  27. This second signature is deprecated, but still available for backwards
  28. compatibility. Use the first signature instead.
  29. It sets the given ``<cachevariable>`` to a command-line string as
  30. above but without the :option:`--target <cmake--build --target>` option.
  31. The ``<makecommand>`` is ignored but should be the full path to
  32. devenv, nmake, make or one of the end user build tools
  33. for legacy invocations.
  34. .. note::
  35. In CMake versions prior to 3.0 this command returned a command
  36. line that directly invokes the native build tool for the current
  37. generator. Their implementation of the ``PROJECT_NAME`` option
  38. had no useful effects, so CMake now warns on use of the option.