1 .. cmake-manual-description: CMake Command-Line Reference
11 `Generate a Project Buildsystem`_
12 cmake [<options>] <path-to-source | path-to-existing-build>
13 cmake [<options>] -S <path-to-source> -B <path-to-build>
16 cmake --build <dir> [<options>] [-- <build-tool-options>]
19 cmake --install <dir> [<options>]
25 cmake [-D <var>=<value>]... -P <cmake-script-file>
27 `Run a Command-Line Tool`_
28 cmake -E <command> [<options>]
30 `Run the Find-Package Tool`_
31 cmake --find-package [<options>]
33 `Run a Workflow Preset`_
34 cmake --workflow [<options>]
37 cmake --help[-<topic>]
42 The **cmake** executable is the command-line interface of the cross-platform
43 buildsystem generator CMake. The above `Synopsis`_ lists various actions
44 the tool can perform as described in sections below.
46 To build a software project with CMake, `Generate a Project Buildsystem`_.
47 Optionally use **cmake** to `Build a Project`_, `Install a Project`_ or just
48 run the corresponding build tool (e.g. ``make``) directly. **cmake** can also
49 be used to `View Help`_.
51 The other actions are meant for use by software developers writing
52 scripts in the :manual:`CMake language <cmake-language(7)>` to support
55 For graphical user interfaces that may be used in place of **cmake**,
56 see :manual:`ccmake <ccmake(1)>` and :manual:`cmake-gui <cmake-gui(1)>`.
57 For command-line interfaces to the CMake testing and packaging facilities,
58 see :manual:`ctest <ctest(1)>` and :manual:`cpack <cpack(1)>`.
60 For more information on CMake at large, `see also`_ the links at the end
64 Introduction to CMake Buildsystems
65 ==================================
67 A *buildsystem* describes how to build a project's executables and libraries
68 from its source code using a *build tool* to automate the process. For
69 example, a buildsystem may be a ``Makefile`` for use with a command-line
70 ``make`` tool or a project file for an Integrated Development Environment
71 (IDE). In order to avoid maintaining multiple such buildsystems, a project
72 may specify its buildsystem abstractly using files written in the
73 :manual:`CMake language <cmake-language(7)>`. From these files CMake
74 generates a preferred buildsystem locally for each user through a backend
77 To generate a buildsystem with CMake, the following must be selected:
80 The top-level directory containing source files provided by the project.
81 The project specifies its buildsystem using files as described in the
82 :manual:`cmake-language(7)` manual, starting with a top-level file named
83 ``CMakeLists.txt``. These files specify build targets and their
84 dependencies as described in the :manual:`cmake-buildsystem(7)` manual.
87 The top-level directory in which buildsystem files and build output
88 artifacts (e.g. executables and libraries) are to be stored.
89 CMake will write a ``CMakeCache.txt`` file to identify the directory
90 as a build tree and store persistent information such as buildsystem
91 configuration options.
93 To maintain a pristine source tree, perform an *out-of-source* build
94 by using a separate dedicated build tree. An *in-source* build in
95 which the build tree is placed in the same directory as the source
96 tree is also supported, but discouraged.
99 This chooses the kind of buildsystem to generate. See the
100 :manual:`cmake-generators(7)` manual for documentation of all generators.
101 Run :option:`cmake --help` to see a list of generators available locally.
102 Optionally use the :option:`-G <cmake -G>` option below to specify a
103 generator, or simply accept the default CMake chooses for the current
106 When using one of the :ref:`Command-Line Build Tool Generators`
107 CMake expects that the environment needed by the compiler toolchain
108 is already configured in the shell. When using one of the
109 :ref:`IDE Build Tool Generators`, no particular environment is needed.
111 .. _`Generate a Project Buildsystem`:
113 Generate a Project Buildsystem
114 ==============================
116 Run CMake with one of the following command signatures to specify the
117 source and build trees and generate a buildsystem:
119 ``cmake [<options>] <path-to-source>``
120 Uses the current working directory as the build tree, and
121 ``<path-to-source>`` as the source tree. The specified path may
122 be absolute or relative to the current working directory.
123 The source tree must contain a ``CMakeLists.txt`` file and must
124 *not* contain a ``CMakeCache.txt`` file because the latter
125 identifies an existing build tree. For example:
127 .. code-block:: console
129 $ mkdir build ; cd build
132 ``cmake [<options>] <path-to-existing-build>``
133 Uses ``<path-to-existing-build>`` as the build tree, and loads the
134 path to the source tree from its ``CMakeCache.txt`` file, which must
135 have already been generated by a previous run of CMake. The specified
136 path may be absolute or relative to the current working directory.
139 .. code-block:: console
144 ``cmake [<options>] -S <path-to-source> -B <path-to-build>``
146 .. versionadded:: 3.13
148 Uses ``<path-to-build>`` as the build tree and ``<path-to-source>``
149 as the source tree. The specified paths may be absolute or relative
150 to the current working directory. The source tree must contain a
151 ``CMakeLists.txt`` file. The build tree will be created automatically
152 if it does not already exist. For example:
154 .. code-block:: console
156 $ cmake -S src -B build
158 In all cases the ``<options>`` may be zero or more of the `Options`_ below.
160 The above styles for specifying the source and build trees may be mixed.
161 Paths specified with :option:`-S <cmake -S>` or :option:`-B <cmake -B>`
162 are always classified as source or build trees, respectively. Paths
163 specified with plain arguments are classified based on their content
164 and the types of paths given earlier. If only one type of path is given,
165 the current working directory (cwd) is used for the other. For example:
167 ============================== ============ ===========
168 Command Line Source Dir Build Dir
169 ============================== ============ ===========
170 ``cmake src`` ``src`` `cwd`
171 ``cmake build`` (existing) `loaded` ``build``
172 ``cmake -S src`` ``src`` `cwd`
173 ``cmake -S src build`` ``src`` ``build``
174 ``cmake -S src -B build`` ``src`` ``build``
175 ``cmake -B build`` `cwd` ``build``
176 ``cmake -B build src`` ``src`` ``build``
177 ``cmake -B build -S src`` ``src`` ``build``
178 ============================== ============ ===========
180 .. versionchanged:: 3.23
182 CMake warns when multiple source paths are specified. This has never
183 been officially documented or supported, but older versions accidentally
184 accepted multiple source paths and used the last path specified.
185 Avoid passing multiple source path arguments.
187 After generating a buildsystem one may use the corresponding native
188 build tool to build the project. For example, after using the
189 :generator:`Unix Makefiles` generator one may run ``make`` directly:
191 .. code-block:: console
196 Alternatively, one may use **cmake** to `Build a Project`_ by
197 automatically choosing and invoking the appropriate native build tool.
206 .. include:: OPTIONS_BUILD.txt
210 .. versionadded:: 3.24
212 Perform a fresh configuration of the build tree.
213 This removes any existing ``CMakeCache.txt`` file and associated
214 ``CMakeFiles/`` directory, and recreates them from scratch.
218 List non-advanced cached variables.
220 List ``CACHE`` variables will run CMake and list all the variables from
221 the CMake ``CACHE`` that are not marked as ``INTERNAL`` or :prop_cache:`ADVANCED`.
222 This will effectively display current CMake settings, which can then be
223 changed with :option:`-D <cmake -D>` option. Changing some of the variables
224 may result in more variables being created. If ``A`` is specified, then it
225 will display also advanced variables. If ``H`` is specified, it will also
226 display help for each variable.
232 Only load the cache. Do not actually run configure and generate
235 .. option:: --graphviz=<file>
237 Generate graphviz of dependencies, see :module:`CMakeGraphVizOptions` for more.
239 Generate a graphviz input file that will contain all the library and
240 executable dependencies in the project. See the documentation for
241 :module:`CMakeGraphVizOptions` for more details.
243 .. option:: --system-information [file]
245 Dump information about this system.
247 Dump a wide range of information about the current system. If run
248 from the top of a binary tree for a CMake project it will dump
249 additional information such as the cache, log files etc.
251 .. option:: --log-level=<level>
253 Set the log ``<level>``.
255 The :command:`message` command will only output messages of the specified
256 log level or higher. The valid log levels are ``ERROR``, ``WARNING``,
257 ``NOTICE``, ``STATUS`` (default), ``VERBOSE``, ``DEBUG``, or ``TRACE``.
259 To make a log level persist between CMake runs, set
260 :variable:`CMAKE_MESSAGE_LOG_LEVEL` as a cache variable instead.
261 If both the command line option and the variable are given, the command line
262 option takes precedence.
264 For backward compatibility reasons, ``--loglevel`` is also accepted as a
265 synonym for this option.
267 .. versionadded:: 3.25
268 See the :command:`cmake_language` command for a way to
269 :ref:`query the current message logging level <query_message_log_level>`.
271 .. option:: --log-context
273 Enable the :command:`message` command outputting context attached to each
276 This option turns on showing context for the current CMake run only.
277 To make showing the context persistent for all subsequent CMake runs, set
278 :variable:`CMAKE_MESSAGE_CONTEXT_SHOW` as a cache variable instead.
279 When this command line option is given, :variable:`CMAKE_MESSAGE_CONTEXT_SHOW`
282 .. option:: --debug-trycompile
284 Do not delete the files and directories created for
285 :command:`try_compile` / :command:`try_run` calls.
286 This is useful in debugging failed checks.
288 Note that some uses of :command:`try_compile` may use the same build tree,
289 which will limit the usefulness of this option if a project executes more
290 than one :command:`try_compile`. For example, such uses may change results
291 as artifacts from a previous try-compile may cause a different test to either
292 pass or fail incorrectly. This option is best used only when debugging.
294 (With respect to the preceding, the :command:`try_run` command
295 is effectively a :command:`try_compile`. Any combination of the two
296 is subject to the potential issues described.)
298 .. versionadded:: 3.25
300 When this option is enabled, every try-compile check prints a log
301 message reporting the directory in which the check is performed.
303 .. option:: --debug-output
305 Put cmake in a debug mode.
307 Print extra information during the cmake run like stack traces with
308 :command:`message(SEND_ERROR)` calls.
310 .. option:: --debug-find
312 Put cmake find commands in a debug mode.
314 Print extra find call information during the cmake run to standard
315 error. Output is designed for human consumption and not for parsing.
316 See also the :variable:`CMAKE_FIND_DEBUG_MODE` variable for debugging
317 a more local part of the project.
319 .. option:: --debug-find-pkg=<pkg>[,...]
321 Put cmake find commands in a debug mode when running under calls
322 to :command:`find_package(\<pkg\>) <find_package>`, where ``<pkg>``
323 is an entry in the given comma-separated list of case-sensitive package
326 Like :option:`--debug-find <cmake --debug-find>`, but limiting scope
327 to the specified packages.
329 .. option:: --debug-find-var=<var>[,...]
331 Put cmake find commands in a debug mode when called with ``<var>``
332 as the result variable, where ``<var>`` is an entry in the given
333 comma-separated list.
335 Like :option:`--debug-find <cmake --debug-find>`, but limiting scope
336 to the specified variable names.
340 Put cmake in trace mode.
342 Print a trace of all calls made and from where.
344 .. option:: --trace-expand
346 Put cmake in trace mode.
348 Like :option:`--trace <cmake --trace>`, but with variables expanded.
350 .. option:: --trace-format=<format>
352 Put cmake in trace mode and sets the trace output format.
354 ``<format>`` can be one of the following values.
357 Prints each trace line in a human-readable format. This is the
361 Prints each line as a separate JSON document. Each document is
362 separated by a newline ( ``\n`` ). It is guaranteed that no
363 newline characters will be present inside a JSON document.
370 "file": "/full/path/to/the/CMake/file.txt",
372 "cmd": "add_executable",
373 "args": ["foo", "bar"],
374 "time": 1579512535.9687231,
382 The full path to the CMake source file where the function
386 The line in ``file`` where the function call begins.
389 If the function call spans multiple lines, this field will
390 be set to the line where the function call ends. If the function
391 calls spans a single line, this field will be unset. This field
392 was added in minor version 2 of the ``json-v1`` format.
395 Optional member that is present when the function call was deferred
396 by :command:`cmake_language(DEFER)`. If present, its value is a
397 string containing the deferred call ``<id>``.
400 The name of the function that was called.
403 A string list of all function parameters.
406 Timestamp (seconds since epoch) of the function call.
409 Stack frame depth of the function that was called, within the
410 context of the ``CMakeLists.txt`` being processed currently.
413 Stack frame depth of the function that was called, tracked globally
414 across all ``CMakeLists.txt`` files involved in the trace. This field
415 was added in minor version 2 of the ``json-v1`` format.
417 Additionally, the first JSON document outputted contains the
418 ``version`` key for the current major and minor version of the
434 Indicates the version of the JSON format. The version has a
435 major and minor components following semantic version conventions.
437 .. option:: --trace-source=<file>
439 Put cmake in trace mode, but output only lines of a specified file.
441 Multiple options are allowed.
443 .. option:: --trace-redirect=<file>
445 Put cmake in trace mode and redirect trace output to a file instead of stderr.
447 .. option:: --warn-uninitialized
449 Warn about uninitialized values.
451 Print a warning when an uninitialized variable is used.
453 .. option:: --warn-unused-vars
455 Does nothing. In CMake versions 3.2 and below this enabled warnings about
456 unused variables. In CMake versions 3.3 through 3.18 the option was broken.
457 In CMake 3.19 and above the option has been removed.
459 .. option:: --no-warn-unused-cli
461 Don't warn about command line options.
463 Don't find variables that are declared on the command line, but not
466 .. option:: --check-system-vars
468 Find problems with variable usage in system files.
470 Normally, unused and uninitialized variables are searched for only
471 in :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR`.
472 This flag tells CMake to warn about other files as well.
474 .. option:: --compile-no-warning-as-error
476 Ignore target property :prop_tgt:`COMPILE_WARNING_AS_ERROR` and variable
477 :variable:`CMAKE_COMPILE_WARNING_AS_ERROR`, preventing warnings from being
478 treated as errors on compile.
480 .. option:: --profiling-output=<path>
482 Used in conjunction with
483 :option:`--profiling-format <cmake --profiling-format>` to output to a
486 .. option:: --profiling-format=<file>
488 Enable the output of profiling data of CMake script in the given format.
490 This can aid performance analysis of CMake scripts executed. Third party
491 applications should be used to process the output into human readable format.
493 Currently supported values are:
494 ``google-trace`` Outputs in Google Trace Format, which can be parsed by the
495 about:tracing tab of Google Chrome or using a plugin for a tool like Trace
498 .. option:: --preset <preset>, --preset=<preset>
500 Reads a :manual:`preset <cmake-presets(7)>` from
501 ``<path-to-source>/CMakePresets.json`` and
502 ``<path-to-source>/CMakeUserPresets.json``. The preset may specify the
503 generator and the build directory, and a list of variables and other
504 arguments to pass to CMake. The current working directory must contain
505 CMake preset files. The :manual:`CMake GUI <cmake-gui(1)>` can
506 also recognize ``CMakePresets.json`` and ``CMakeUserPresets.json`` files. For
507 full details on these files, see :manual:`cmake-presets(7)`.
509 The presets are read before all other command line options. The options
510 specified by the preset (variables, generator, etc.) can all be overridden by
511 manually specifying them on the command line. For example, if the preset sets
512 a variable called ``MYVAR`` to ``1``, but the user sets it to ``2`` with a
513 ``-D`` argument, the value ``2`` is preferred.
515 .. option:: --list-presets[=<type>]
517 Lists the available presets of the specified ``<type>``. Valid values for
518 ``<type>`` are ``configure``, ``build``, ``test``, ``package``, or ``all``.
519 If ``<type>`` is omitted, ``configure`` is assumed. The current working
520 directory must contain CMake preset files.
522 .. _`Build Tool Mode`:
529 CMake provides a command-line signature to build an already-generated
532 .. code-block:: shell
534 cmake --build <dir> [<options>] [-- <build-tool-options>]
535 cmake --build --preset <preset> [<options>] [-- <build-tool-options>]
537 This abstracts a native build tool's command-line interface with the
540 .. option:: --build <dir>
542 Project binary directory to be built. This is required (unless a preset
543 is specified) and must be first.
545 .. program:: cmake--build
547 .. option:: --preset <preset>, --preset=<preset>
549 Use a build preset to specify build options. The project binary directory
550 is inferred from the ``configurePreset`` key. The current working directory
551 must contain CMake preset files.
552 See :manual:`preset <cmake-presets(7)>` for more details.
554 .. option:: --list-presets
556 Lists the available build presets. The current working directory must
557 contain CMake preset files.
559 .. option:: -j [<jobs>], --parallel [<jobs>]
561 .. versionadded:: 3.12
563 The maximum number of concurrent processes to use when building.
564 If ``<jobs>`` is omitted the native build tool's default number is used.
566 The :envvar:`CMAKE_BUILD_PARALLEL_LEVEL` environment variable, if set,
567 specifies a default parallel level when this option is not given.
569 Some native build tools always build in parallel. The use of ``<jobs>``
570 value of ``1`` can be used to limit to a single job.
572 .. option:: -t <tgt>..., --target <tgt>...
574 Build ``<tgt>`` instead of the default target. Multiple targets may be
575 given, separated by spaces.
577 .. option:: --config <cfg>
579 For multi-configuration tools, choose configuration ``<cfg>``.
581 .. option:: --clean-first
583 Build target ``clean`` first, then build.
584 (To clean only, use :option:`--target clean <cmake--build --target>`.)
586 .. option:: --resolve-package-references=<value>
588 .. versionadded:: 3.23
590 Resolve remote package references from external package managers (e.g. NuGet)
591 before build. When ``<value>`` is set to ``on`` (default), packages will be
592 restored before building a target. When ``<value>`` is set to ``only``, the
593 packages will be restored, but no build will be performed. When
594 ``<value>`` is set to ``off``, no packages will be restored.
596 If the target does not define any package references, this option does nothing.
598 This setting can be specified in a build preset (using
599 ``resolvePackageReferences``). The preset setting will be ignored, if this
600 command line option is specified.
602 If no command line parameter or preset option are provided, an environment-
603 specific cache variable will be evaluated to decide, if package restoration
606 When using the Visual Studio generator, package references are defined
607 using the :prop_tgt:`VS_PACKAGE_REFERENCES` property. Package references
608 are restored using NuGet. It can be disabled by setting the
609 ``CMAKE_VS_NUGET_PACKAGE_RESTORE`` variable to ``OFF``.
611 .. option:: --use-stderr
613 Ignored. Behavior is default in CMake >= 3.0.
615 .. option:: -v, --verbose
617 Enable verbose output - if supported - including the build commands to be
620 This option can be omitted if :envvar:`VERBOSE` environment variable or
621 :variable:`CMAKE_VERBOSE_MAKEFILE` cached variable is set.
626 Pass remaining options to the native tool.
628 Run :option:`cmake --build` with no options for quick help.
635 CMake provides a command-line signature to install an already-generated
638 .. code-block:: shell
640 cmake --install <dir> [<options>]
642 This may be used after building a project to run installation without
643 using the generated build system or the native build tool.
646 .. option:: --install <dir>
648 Project binary directory to install. This is required and must be first.
650 .. program:: cmake--install
652 .. option:: --config <cfg>
654 For multi-configuration generators, choose configuration ``<cfg>``.
656 .. option:: --component <comp>
658 Component-based install. Only install component ``<comp>``.
660 .. option:: --default-directory-permissions <permissions>
662 Default directory install permissions. Permissions in format ``<u=rwx,g=rx,o=rx>``.
664 .. option:: --prefix <prefix>
666 Override the installation prefix, :variable:`CMAKE_INSTALL_PREFIX`.
670 Strip before installing.
672 .. option:: -v, --verbose
674 Enable verbose output.
676 This option can be omitted if :envvar:`VERBOSE` environment variable is set.
678 Run :option:`cmake --install` with no options for quick help.
685 .. code-block:: shell
689 Open the generated project in the associated application. This is only
690 supported by some generators.
693 .. _`Script Processing Mode`:
700 .. code-block:: shell
702 cmake [-D <var>=<value>]... -P <cmake-script-file> [-- <unparsed-options>...]
706 .. option:: -D <var>=<value>
708 Define a variable for script mode.
712 .. option:: -P <cmake-script-file>
714 Process the given cmake file as a script written in the CMake
715 language. No configure or generate step is performed and the cache
716 is not modified. If variables are defined using ``-D``, this must be
717 done before the ``-P`` argument.
719 Any options after ``--`` are not parsed by CMake, but they are still included
720 in the set of :variable:`CMAKE_ARGV<n> <CMAKE_ARGV0>` variables passed to the
721 script (including the ``--`` itself).
724 .. _`Run a Command-Line Tool`:
726 Run a Command-Line Tool
727 =======================
731 CMake provides builtin command-line tools through the signature
733 .. code-block:: shell
735 cmake -E <command> [<options>]
737 .. option:: -E [help]
739 Run ``cmake -E`` or ``cmake -E help`` for a summary of commands.
743 Available commands are:
745 .. option:: capabilities
747 .. versionadded:: 3.7
749 Report cmake capabilities in JSON format. The output is a JSON object
750 with the following keys:
753 A JSON object with version information. Keys are:
756 The full version string as displayed by cmake :option:`--version <cmake --version>`.
758 The major version number in integer form.
760 The minor version number in integer form.
762 The patch level in integer form.
764 The cmake version suffix string.
766 A bool that is set if the cmake build is from a dirty tree.
769 A list available generators. Each generator is a JSON object with the
773 A string containing the name of the generator.
775 ``true`` if the generator supports toolsets and ``false`` otherwise.
777 ``true`` if the generator supports platforms and ``false`` otherwise.
778 ``supportedPlatforms``
779 .. versionadded:: 3.21
781 Optional member that may be present when the generator supports
782 platform specification via :variable:`CMAKE_GENERATOR_PLATFORM`
783 (:option:`-A ... <cmake -A>`). The value is a list of platforms known to
786 A list of strings with all the extra generators compatible with
790 Optional member that is present when the :manual:`cmake-file-api(7)`
791 is available. The value is a JSON object with one member:
794 A JSON array containing zero or more supported file-api requests.
795 Each request is a JSON object with members:
798 Specifies one of the supported :ref:`file-api object kinds`.
801 A JSON array whose elements are each a JSON object containing
802 ``major`` and ``minor`` members specifying non-negative integer
806 ``true`` if cmake supports server-mode and ``false`` otherwise.
807 Always false since CMake 3.20.
810 .. versionadded:: 3.25
812 ``true`` if TLS support is enabled and ``false`` otherwise.
814 .. option:: cat [--] <files>...
816 .. versionadded:: 3.18
818 Concatenate files and print on the standard output.
820 .. program:: cmake-E_cat
824 .. versionadded:: 3.24
826 Added support for the double dash argument ``--``. This basic implementation
827 of ``cat`` does not support any options, so using a option starting with
828 ``-`` will result in an error. Use ``--`` to indicate the end of options, in
829 case a file starts with ``-``.
833 .. option:: chdir <dir> <cmd> [<arg>...]
835 Change the current working directory and run a command.
837 .. option:: compare_files [--ignore-eol] <file1> <file2>
839 Check if ``<file1>`` is same as ``<file2>``. If files are the same,
840 then returns ``0``, if not it returns ``1``. In case of invalid
841 arguments, it returns 2.
843 .. program:: cmake-E_compare_files
845 .. option:: --ignore-eol
847 .. versionadded:: 3.14
849 The option implies line-wise comparison and ignores LF/CRLF differences.
853 .. option:: copy <file>... <destination>
855 Copy files to ``<destination>`` (either file or directory).
856 If multiple files are specified, the ``<destination>`` must be
857 directory and it must exist. Wildcards are not supported.
858 ``copy`` does follow symlinks. That means it does not copy symlinks,
859 but the files or directories it point to.
861 .. versionadded:: 3.5
862 Support for multiple input files.
864 .. option:: copy_directory <dir>... <destination>
866 Copy content of ``<dir>...`` directories to ``<destination>`` directory.
867 If ``<destination>`` directory does not exist it will be created.
868 ``copy_directory`` does follow symlinks.
870 .. versionadded:: 3.5
871 Support for multiple input directories.
873 .. versionadded:: 3.15
874 The command now fails when the source directory does not exist.
875 Previously it succeeded by creating an empty destination directory.
877 .. option:: copy_if_different <file>... <destination>
879 Copy files to ``<destination>`` (either file or directory) if
881 If multiple files are specified, the ``<destination>`` must be
882 directory and it must exist.
883 ``copy_if_different`` does follow symlinks.
885 .. versionadded:: 3.5
886 Support for multiple input files.
888 .. option:: create_symlink <old> <new>
890 Create a symbolic link ``<new>`` naming ``<old>``.
892 .. versionadded:: 3.13
893 Support for creating symlinks on Windows.
896 Path to where ``<new>`` symbolic link will be created has to exist beforehand.
898 .. option:: create_hardlink <old> <new>
900 .. versionadded:: 3.19
902 Create a hard link ``<new>`` naming ``<old>``.
905 Path to where ``<new>`` hard link will be created has to exist beforehand.
906 ``<old>`` has to exist beforehand.
908 .. option:: echo [<string>...]
910 Displays arguments as text.
912 .. option:: echo_append [<string>...]
914 Displays arguments as text but no new line.
916 .. option:: env [<options>] [--] <command> [<arg>...]
918 .. versionadded:: 3.1
920 Run command in a modified environment. Options are:
922 .. program:: cmake-E_env
924 .. option:: NAME=VALUE
926 Replaces the current value of ``NAME`` with ``VALUE``.
928 .. option:: --unset=NAME
930 Unsets the current value of ``NAME``.
932 .. option:: --modify ENVIRONMENT_MODIFICATION
934 .. versionadded:: 3.25
936 Apply a single :prop_test:`ENVIRONMENT_MODIFICATION` operation to the
937 modified environment.
939 The ``NAME=VALUE`` and ``--unset=NAME`` options are equivalent to
940 ``--modify NAME=set:VALUE`` and ``--modify NAME=unset:``, respectively.
941 Note that ``--modify NAME=reset:`` resets ``NAME`` to the value it had
942 when ``cmake`` launched (or unsets it), not to the most recent
943 ``NAME=VALUE`` option.
947 .. versionadded:: 3.24
949 Added support for the double dash argument ``--``. Use ``--`` to stop
950 interpreting options/environment variables and treat the next argument as
951 the command, even if it start with ``-`` or contains a ``=``.
955 .. option:: environment
957 Display the current environment variables.
961 .. versionadded:: 3.16
963 Do nothing, with an exit code of 1.
965 .. option:: make_directory <dir>...
967 Create ``<dir>`` directories. If necessary, create parent
968 directories too. If a directory already exists it will be
971 .. versionadded:: 3.5
972 Support for multiple input directories.
974 .. option:: md5sum <file>...
976 Create MD5 checksum of files in ``md5sum`` compatible format::
978 351abe79cd3800b38cdfb25d45015a15 file1.txt
979 052f86c15bbde68af55c7f7b340ab639 file2.txt
981 .. option:: sha1sum <file>...
983 .. versionadded:: 3.10
985 Create SHA1 checksum of files in ``sha1sum`` compatible format::
987 4bb7932a29e6f73c97bb9272f2bdc393122f86e0 file1.txt
988 1df4c8f318665f9a5f2ed38f55adadb7ef9f559c file2.txt
990 .. option:: sha224sum <file>...
992 .. versionadded:: 3.10
994 Create SHA224 checksum of files in ``sha224sum`` compatible format::
996 b9b9346bc8437bbda630b0b7ddfc5ea9ca157546dbbf4c613192f930 file1.txt
997 6dfbe55f4d2edc5fe5c9197bca51ceaaf824e48eba0cc453088aee24 file2.txt
999 .. option:: sha256sum <file>...
1001 .. versionadded:: 3.10
1003 Create SHA256 checksum of files in ``sha256sum`` compatible format::
1005 76713b23615d31680afeb0e9efe94d47d3d4229191198bb46d7485f9cb191acc file1.txt
1006 15b682ead6c12dedb1baf91231e1e89cfc7974b3787c1e2e01b986bffadae0ea file2.txt
1008 .. option:: sha384sum <file>...
1010 .. versionadded:: 3.10
1012 Create SHA384 checksum of files in ``sha384sum`` compatible format::
1014 acc049fedc091a22f5f2ce39a43b9057fd93c910e9afd76a6411a28a8f2b8a12c73d7129e292f94fc0329c309df49434 file1.txt
1015 668ddeb108710d271ee21c0f3acbd6a7517e2b78f9181c6a2ff3b8943af92b0195dcb7cce48aa3e17893173c0a39e23d file2.txt
1017 .. option:: sha512sum <file>...
1019 .. versionadded:: 3.10
1021 Create SHA512 checksum of files in ``sha512sum`` compatible format::
1023 2a78d7a6c5328cfb1467c63beac8ff21794213901eaadafd48e7800289afbc08e5fb3e86aa31116c945ee3d7bf2a6194489ec6101051083d1108defc8e1dba89 file1.txt
1024 7a0b54896fe5e70cca6dd643ad6f672614b189bf26f8153061c4d219474b05dad08c4e729af9f4b009f1a1a280cb625454bf587c690f4617c27e3aebdf3b7a2d file2.txt
1026 .. option:: remove [-f] <file>...
1028 .. deprecated:: 3.17
1030 Remove the file(s). The planned behavior was that if any of the
1031 listed files already do not exist, the command returns a non-zero exit code,
1032 but no message is logged. The ``-f`` option changes the behavior to return a
1033 zero exit code (i.e. success) in such situations instead.
1034 ``remove`` does not follow symlinks. That means it remove only symlinks
1035 and not files it point to.
1037 The implementation was buggy and always returned 0. It cannot be fixed without
1038 breaking backwards compatibility. Use ``rm`` instead.
1040 .. option:: remove_directory <dir>...
1042 .. deprecated:: 3.17
1044 Remove ``<dir>`` directories and their contents. If a directory does
1045 not exist it will be silently ignored.
1048 .. versionadded:: 3.15
1049 Support for multiple directories.
1051 .. versionadded:: 3.16
1052 If ``<dir>`` is a symlink to a directory, just the symlink will be removed.
1054 .. option:: rename <oldname> <newname>
1056 Rename a file or directory (on one volume). If file with the ``<newname>`` name
1057 already exists, then it will be silently replaced.
1059 .. option:: rm [-rRf] [--] <file|dir>...
1061 .. versionadded:: 3.17
1063 Remove the files ``<file>`` or directories ``<dir>``.
1064 Use ``-r`` or ``-R`` to remove directories and their contents recursively.
1065 If any of the listed files/directories do not exist, the command returns a
1066 non-zero exit code, but no message is logged. The ``-f`` option changes
1067 the behavior to return a zero exit code (i.e. success) in such
1068 situations instead. Use ``--`` to stop interpreting options and treat all
1069 remaining arguments as paths, even if they start with ``-``.
1073 Launch :manual:`cmake-server(7)` mode.
1075 .. option:: sleep <number>...
1077 .. versionadded:: 3.0
1079 Sleep for given number of seconds.
1081 .. option:: tar [cxt][vf][zjJ] file.tar [<options>] [--] [<pathname>...]
1083 Create or extract a tar or zip archive. Options are:
1085 .. program:: cmake-E_tar
1089 Create a new archive containing the specified files.
1090 If used, the ``<pathname>...`` argument is mandatory.
1094 Extract to disk from the archive.
1096 .. versionadded:: 3.15
1097 The ``<pathname>...`` argument could be used to extract only selected files
1099 When extracting selected files or directories, you must provide their exact
1100 names including the path, as printed by list (``-t``).
1104 List archive contents.
1106 .. versionadded:: 3.15
1107 The ``<pathname>...`` argument could be used to list only selected files
1112 Produce verbose output.
1116 Compress the resulting archive with gzip.
1120 Compress the resulting archive with bzip2.
1124 .. versionadded:: 3.1
1126 Compress the resulting archive with XZ.
1130 .. versionadded:: 3.15
1132 Compress the resulting archive with Zstandard.
1134 .. option:: --files-from=<file>
1136 .. versionadded:: 3.1
1138 Read file names from the given file, one per line.
1139 Blank lines are ignored. Lines may not start in ``-``
1140 except for ``--add-file=<name>`` to add files whose
1141 names start in ``-``.
1143 .. option:: --format=<format>
1145 .. versionadded:: 3.3
1147 Specify the format of the archive to be created.
1148 Supported formats are: ``7zip``, ``gnutar``, ``pax``,
1149 ``paxr`` (restricted pax, default), and ``zip``.
1151 .. option:: --mtime=<date>
1153 .. versionadded:: 3.1
1155 Specify modification time recorded in tarball entries.
1159 .. versionadded:: 3.24
1161 Use current local timestamp instead of extracting file timestamps
1166 .. versionadded:: 3.1
1168 Stop interpreting options and treat all remaining arguments
1169 as file names, even if they start with ``-``.
1171 .. versionadded:: 3.1
1172 LZMA (7zip) support.
1174 .. versionadded:: 3.15
1175 The command now continues adding files to an archive even if some of the
1176 files are not readable. This behavior is more consistent with the classic
1177 ``tar`` tool. The command now also parses all flags, and if an invalid flag
1178 was provided, a warning is issued.
1180 .. program:: cmake-E
1182 .. option:: time <command> [<args>...]
1184 Run command and display elapsed time.
1186 .. versionadded:: 3.5
1187 The command now properly passes arguments with spaces or special characters
1188 through to the child process. This may break scripts that worked around the
1189 bug with their own extra quoting or escaping.
1191 .. option:: touch <file>...
1193 Creates ``<file>`` if file do not exist.
1194 If ``<file>`` exists, it is changing ``<file>`` access and modification times.
1196 .. option:: touch_nocreate <file>...
1198 Touch a file if it exists but do not create it. If a file does
1199 not exist it will be silently ignored.
1203 .. versionadded:: 3.16
1205 Do nothing, with an exit code of 0.
1207 Windows-specific Command-Line Tools
1208 -----------------------------------
1210 The following ``cmake -E`` commands are available only on Windows:
1212 .. option:: delete_regv <key>
1214 Delete Windows registry value.
1216 .. option:: env_vs8_wince <sdkname>
1218 .. versionadded:: 3.2
1220 Displays a batch file which sets the environment for the provided
1221 Windows CE SDK installed in VS2005.
1223 .. option:: env_vs9_wince <sdkname>
1225 .. versionadded:: 3.2
1227 Displays a batch file which sets the environment for the provided
1228 Windows CE SDK installed in VS2008.
1230 .. option:: write_regv <key> <value>
1232 Write Windows registry value.
1235 Run the Find-Package Tool
1236 =========================
1238 .. program:: cmake--find-package
1240 CMake provides a pkg-config like helper for Makefile-based projects:
1242 .. code-block:: shell
1244 cmake --find-package [<options>]
1246 It searches a package using :command:`find_package()` and prints the
1247 resulting flags to stdout. This can be used instead of pkg-config
1248 to find installed libraries in plain Makefile-based projects or in
1249 autoconf-based projects (via ``share/aclocal/cmake.m4``).
1252 This mode is not well-supported due to some technical limitations.
1253 It is kept for compatibility but should not be used in new projects.
1255 .. _`Workflow Mode`:
1257 Run a Workflow Preset
1258 =====================
1262 :manual:`CMake Presets <cmake-presets(7)>` provides a way to execute multiple
1263 build steps in order:
1265 .. code-block:: shell
1267 cmake --workflow [<options>]
1271 .. option:: --workflow
1273 Select a :ref:`Workflow Preset` using one of the following options.
1275 .. program:: cmake--workflow
1277 .. option:: --preset <preset>, --preset=<preset>
1279 Use a workflow preset to specify a workflow. The project binary directory
1280 is inferred from the initial configure preset. The current working directory
1281 must contain CMake preset files.
1282 See :manual:`preset <cmake-presets(7)>` for more details.
1284 .. option:: --list-presets
1286 Lists the available workflow presets. The current working directory must
1287 contain CMake preset files.
1291 Perform a fresh configuration of the build tree.
1292 This removes any existing ``CMakeCache.txt`` file and associated
1293 ``CMakeFiles/`` directory, and recreates them from scratch.
1300 To print selected pages from the CMake documentation, use
1302 .. code-block:: shell
1304 cmake --help[-<topic>]
1306 with one of the following options:
1308 .. include:: OPTIONS_HELP.txt
1310 To view the presets available for a project, use
1312 .. code-block:: shell
1314 cmake <source-dir> --list-presets
1317 .. _`CMake Exit Code`:
1319 Return Value (Exit Code)
1320 ========================
1322 Upon regular termination, the ``cmake`` executable returns the exit code ``0``.
1324 If termination is caused by the command :command:`message(FATAL_ERROR)`,
1325 or another error condition, then a non-zero exit code is returned.
1331 .. include:: LINKS.txt