157ea5f9df4d9f411f531bd3772ae568ea67909b
[platform/upstream/cmake.git] / Help / manual / cmake.1.rst
1 .. cmake-manual-description: CMake Command-Line Reference
2
3 cmake(1)
4 ********
5
6 Synopsis
7 ========
8
9 .. parsed-literal::
10
11  `Generate a Project Buildsystem`_
12   cmake [<options>] <path-to-source>
13   cmake [<options>] <path-to-existing-build>
14   cmake [<options>] -S <path-to-source> -B <path-to-build>
15
16  `Build a Project`_
17   cmake --build <dir> [<options>] [-- <build-tool-options>]
18
19  `Install a Project`_
20   cmake --install <dir> [<options>]
21
22  `Open a Project`_
23   cmake --open <dir>
24
25  `Run a Script`_
26   cmake [{-D <var>=<value>}...] -P <cmake-script-file>
27
28  `Run a Command-Line Tool`_
29   cmake -E <command> [<options>]
30
31  `Run the Find-Package Tool`_
32   cmake --find-package [<options>]
33
34  `View Help`_
35   cmake --help[-<topic>]
36
37 Description
38 ===========
39
40 The **cmake** executable is the command-line interface of the cross-platform
41 buildsystem generator CMake.  The above `Synopsis`_ lists various actions
42 the tool can perform as described in sections below.
43
44 To build a software project with CMake, `Generate a Project Buildsystem`_.
45 Optionally use **cmake** to `Build a Project`_, `Install a Project`_ or just
46 run the corresponding build tool (e.g. ``make``) directly.  **cmake** can also
47 be used to `View Help`_.
48
49 The other actions are meant for use by software developers writing
50 scripts in the :manual:`CMake language <cmake-language(7)>` to support
51 their builds.
52
53 For graphical user interfaces that may be used in place of **cmake**,
54 see :manual:`ccmake <ccmake(1)>` and :manual:`cmake-gui <cmake-gui(1)>`.
55 For command-line interfaces to the CMake testing and packaging facilities,
56 see :manual:`ctest <ctest(1)>` and :manual:`cpack <cpack(1)>`.
57
58 For more information on CMake at large, `see also`_ the links at the end
59 of this manual.
60
61
62 Introduction to CMake Buildsystems
63 ==================================
64
65 A *buildsystem* describes how to build a project's executables and libraries
66 from its source code using a *build tool* to automate the process.  For
67 example, a buildsystem may be a ``Makefile`` for use with a command-line
68 ``make`` tool or a project file for an Integrated Development Environment
69 (IDE).  In order to avoid maintaining multiple such buildsystems, a project
70 may specify its buildsystem abstractly using files written in the
71 :manual:`CMake language <cmake-language(7)>`.  From these files CMake
72 generates a preferred buildsystem locally for each user through a backend
73 called a *generator*.
74
75 To generate a buildsystem with CMake, the following must be selected:
76
77 Source Tree
78   The top-level directory containing source files provided by the project.
79   The project specifies its buildsystem using files as described in the
80   :manual:`cmake-language(7)` manual, starting with a top-level file named
81   ``CMakeLists.txt``.  These files specify build targets and their
82   dependencies as described in the :manual:`cmake-buildsystem(7)` manual.
83
84 Build Tree
85   The top-level directory in which buildsystem files and build output
86   artifacts (e.g. executables and libraries) are to be stored.
87   CMake will write a ``CMakeCache.txt`` file to identify the directory
88   as a build tree and store persistent information such as buildsystem
89   configuration options.
90
91   To maintain a pristine source tree, perform an *out-of-source* build
92   by using a separate dedicated build tree.  An *in-source* build in
93   which the build tree is placed in the same directory as the source
94   tree is also supported, but discouraged.
95
96 Generator
97   This chooses the kind of buildsystem to generate.  See the
98   :manual:`cmake-generators(7)` manual for documentation of all generators.
99   Run ``cmake --help`` to see a list of generators available locally.
100   Optionally use the ``-G`` option below to specify a generator, or simply
101   accept the default CMake chooses for the current platform.
102
103   When using one of the :ref:`Command-Line Build Tool Generators`
104   CMake expects that the environment needed by the compiler toolchain
105   is already configured in the shell.  When using one of the
106   :ref:`IDE Build Tool Generators`, no particular environment is needed.
107
108
109 Generate a Project Buildsystem
110 ==============================
111
112 Run CMake with one of the following command signatures to specify the
113 source and build trees and generate a buildsystem:
114
115 ``cmake [<options>] <path-to-source>``
116   Uses the current working directory as the build tree, and
117   ``<path-to-source>`` as the source tree.  The specified path may
118   be absolute or relative to the current working directory.
119   The source tree must contain a ``CMakeLists.txt`` file and must
120   *not* contain a ``CMakeCache.txt`` file because the latter
121   identifies an existing build tree.  For example:
122
123   .. code-block:: console
124
125     $ mkdir build ; cd build
126     $ cmake ../src
127
128 ``cmake [<options>] <path-to-existing-build>``
129   Uses ``<path-to-existing-build>`` as the build tree, and loads the
130   path to the source tree from its ``CMakeCache.txt`` file, which must
131   have already been generated by a previous run of CMake.  The specified
132   path may be absolute or relative to the current working directory.
133   For example:
134
135   .. code-block:: console
136
137     $ cd build
138     $ cmake .
139
140 ``cmake [<options>] -S <path-to-source> -B <path-to-build>``
141   Uses ``<path-to-build>`` as the build tree and ``<path-to-source>``
142   as the source tree.  The specified paths may be absolute or relative
143   to the current working directory.  The source tree must contain a
144   ``CMakeLists.txt`` file.  The build tree will be created automatically
145   if it does not already exist.  For example:
146
147   .. code-block:: console
148
149     $ cmake -S src -B build
150
151 In all cases the ``<options>`` may be zero or more of the `Options`_ below.
152
153 After generating a buildsystem one may use the corresponding native
154 build tool to build the project.  For example, after using the
155 :generator:`Unix Makefiles` generator one may run ``make`` directly:
156
157   .. code-block:: console
158
159     $ make
160     $ make install
161
162 Alternatively, one may use **cmake** to `Build a Project`_ by
163 automatically choosing and invoking the appropriate native build tool.
164
165 .. _`CMake Options`:
166
167 Options
168 -------
169
170 .. include:: OPTIONS_BUILD.txt
171
172 ``-L[A][H]``
173  List non-advanced cached variables.
174
175  List ``CACHE`` variables will run CMake and list all the variables from
176  the CMake ``CACHE`` that are not marked as ``INTERNAL`` or :prop_cache:`ADVANCED`.
177  This will effectively display current CMake settings, which can then be
178  changed with ``-D`` option.  Changing some of the variables may result
179  in more variables being created.  If ``A`` is specified, then it will
180  display also advanced variables.  If ``H`` is specified, it will also
181  display help for each variable.
182
183 ``-N``
184  View mode only.
185
186  Only load the cache.  Do not actually run configure and generate
187  steps.
188
189 ``--graphviz=[file]``
190  Generate graphviz of dependencies, see :module:`CMakeGraphVizOptions` for more.
191
192  Generate a graphviz input file that will contain all the library and
193  executable dependencies in the project.  See the documentation for
194  :module:`CMakeGraphVizOptions` for more details.
195
196 ``--system-information [file]``
197  Dump information about this system.
198
199  Dump a wide range of information about the current system.  If run
200  from the top of a binary tree for a CMake project it will dump
201  additional information such as the cache, log files etc.
202
203 ``--log-level=<ERROR|WARNING|NOTICE|STATUS|VERBOSE|DEBUG|TRACE>``
204  Set the log level.
205
206  The :command:`message` command will only output messages of the specified
207  log level or higher.  The default log level is ``STATUS``.
208
209  To make a log level persist between CMake runs, set
210  :variable:`CMAKE_MESSAGE_LOG_LEVEL` as a cache variable instead.
211  If both the command line option and the variable are given, the command line
212  option takes precedence.
213
214  For backward compatibility reasons, ``--loglevel`` is also accepted as a
215  synonym for this option.
216
217 ``--log-context``
218  Enable the :command:`message` command outputting context attached to each
219  message.
220
221  This option turns on showing context for the current CMake run only.
222  To make showing the context persistent for all subsequent CMake runs, set
223  :variable:`CMAKE_MESSAGE_CONTEXT_SHOW` as a cache variable instead.
224  When this command line option is given, :variable:`CMAKE_MESSAGE_CONTEXT_SHOW`
225  is ignored.
226
227 ``--debug-trycompile``
228  Do not delete the :command:`try_compile` build tree.
229  Only useful on one :command:`try_compile` at a time.
230
231  Do not delete the files and directories created for :command:`try_compile`
232  calls.  This is useful in debugging failed try_compiles.  It may
233  however change the results of the try-compiles as old junk from a
234  previous try-compile may cause a different test to either pass or
235  fail incorrectly.  This option is best used for one try-compile at a
236  time, and only when debugging.
237
238 ``--debug-output``
239  Put cmake in a debug mode.
240
241  Print extra information during the cmake run like stack traces with
242  :command:`message(SEND_ERROR)` calls.
243
244 ``--debug-find``
245  Put cmake find commands in a debug mode.
246
247  Print extra find call information during the cmake run to standard
248  error. Output is designed for human consumption and not for parsing.
249  See also the :variable:`CMAKE_FIND_DEBUG_MODE` variable for debugging
250  a more local part of the project.
251
252 ``--trace``
253  Put cmake in trace mode.
254
255  Print a trace of all calls made and from where.
256
257 ``--trace-expand``
258  Put cmake in trace mode.
259
260  Like ``--trace``, but with variables expanded.
261
262 ``--trace-format=<format>``
263  Put cmake in trace mode and sets the trace output format.
264
265  ``<format>`` can be one of the following values.
266
267    ``human``
268      Prints each trace line in a human-readable format. This is the
269      default format.
270
271    ``json-v1``
272      Prints each line as a separate JSON document. Each document is
273      separated by a newline ( ``\n`` ). It is guaranteed that no
274      newline characters will be present inside a JSON document.
275
276      JSON trace format:
277
278      .. code-block:: json
279
280        {
281          "file": "/full/path/to/the/CMake/file.txt",
282          "line": 0,
283          "cmd": "add_executable",
284          "args": ["foo", "bar"],
285          "time": 1579512535.9687231,
286          "frame": 2
287        }
288
289      The members are:
290
291      ``file``
292        The full path to the CMake source file where the function
293        was called.
294
295      ``line``
296        The line in ``file`` of the function call.
297
298      ``defer``
299        Optional member that is present when the function call was deferred
300        by :command:`cmake_language(DEFER)`.  If present, its value is a
301        string containing the deferred call ``<id>``.
302
303      ``cmd``
304        The name of the function that was called.
305
306      ``args``
307        A string list of all function parameters.
308
309      ``time``
310        Timestamp (seconds since epoch) of the function call.
311
312      ``frame``
313        Stack frame depth of the function that was called.
314
315      Additionally, the first JSON document outputted contains the
316      ``version`` key for the current major and minor version of the
317
318      JSON trace format:
319
320      .. code-block:: json
321
322        {
323          "version": {
324            "major": 1,
325            "minor": 1
326          }
327        }
328
329      The members are:
330
331      ``version``
332        Indicates the version of the JSON format. The version has a
333        major and minor components following semantic version conventions.
334
335 ``--trace-source=<file>``
336  Put cmake in trace mode, but output only lines of a specified file.
337
338  Multiple options are allowed.
339
340 ``--trace-redirect=<file>``
341  Put cmake in trace mode and redirect trace output to a file instead of stderr.
342
343 ``--warn-uninitialized``
344  Warn about uninitialized values.
345
346  Print a warning when an uninitialized variable is used.
347
348 ``--warn-unused-vars``
349  Does nothing.  In CMake versions 3.2 and below this enabled warnings about
350  unused variables.  In CMake versions 3.3 through 3.18 the option was broken.
351  In CMake 3.19 and above the option has been removed.
352
353 ``--no-warn-unused-cli``
354  Don't warn about command line options.
355
356  Don't find variables that are declared on the command line, but not
357  used.
358
359 ``--check-system-vars``
360  Find problems with variable usage in system files.
361
362  Normally, unused and uninitialized variables are searched for only
363  in :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR`.
364  This flag tells CMake to warn about other files as well.
365
366 ``--profiling-output=<path>``
367  Used in conjunction with ``--profiling-format`` to output to a given path.
368
369 ``--profiling-format=<file>``
370  Enable the output of profiling data of CMake script in the given format.
371
372  This can aid performance analysis of CMake scripts executed. Third party
373  applications should be used to process the output into human readable format.
374
375  Currently supported values are:
376  ``google-trace`` Outputs in Google Trace Format, which can be parsed by the
377  about:tracing tab of Google Chrome or using a plugin for a tool like Trace
378  Compass.
379
380 ``--preset <preset>``, ``--preset=<preset>``
381  Reads a :manual:`preset <cmake-presets(7)>` from
382  ``<path-to-source>/CMakePresets.json`` and
383  ``<path-to-source>/CMakeUserPresets.json``. The preset specifies the
384  generator and the build directory, and optionally a list of variables and
385  other arguments to pass to CMake. The current working directory must contain
386  CMake preset files. The :manual:`CMake GUI <cmake-gui(1)>` can
387  also recognize ``CMakePresets.json`` and ``CMakeUserPresets.json`` files. For
388  full details on these files, see :manual:`cmake-presets(7)`.
389
390  The presets are read before all other command line options. The options
391  specified by the preset (variables, generator, etc.) can all be overridden by
392  manually specifying them on the command line. For example, if the preset sets
393  a variable called ``MYVAR`` to ``1``, but the user sets it to ``2`` with a
394  ``-D`` argument, the value ``2`` is preferred.
395
396 ``--list-presets, --list-presets=<[configure | build | test | all]>``
397  Lists the available presets. If no option is specified only configure presets
398  will be listed. The current working directory must contain CMake preset files.
399
400 .. _`Build Tool Mode`:
401
402 Build a Project
403 ===============
404
405 CMake provides a command-line signature to build an already-generated
406 project binary tree:
407
408 .. code-block:: shell
409
410   cmake --build [<dir> | --preset <preset>] [<options>] [-- <build-tool-options>]
411
412 This abstracts a native build tool's command-line interface with the
413 following options:
414
415 ``--build <dir>``
416   Project binary directory to be built.  This is required (unless a preset
417   is specified) and must be first.
418
419 ``--preset <preset>``, ``--preset=<preset>``
420   Use a build preset to specify build options. The project binary directory
421   is inferred from the ``configurePreset`` key. The current working directory
422   must contain CMake preset files.
423   See :manual:`preset <cmake-presets(7)>` for more details.
424
425 ``--list-presets``
426   Lists the available build presets. The current working directory must
427   contain CMake preset files.
428
429 ``--parallel [<jobs>], -j [<jobs>]``
430   The maximum number of concurrent processes to use when building.
431   If ``<jobs>`` is omitted the native build tool's default number is used.
432
433   The :envvar:`CMAKE_BUILD_PARALLEL_LEVEL` environment variable, if set,
434   specifies a default parallel level when this option is not given.
435
436   Some native build tools always build in parallel.  The use of ``<jobs>``
437   value of ``1`` can be used to limit to a single job.
438
439 ``--target <tgt>..., -t <tgt>...``
440   Build ``<tgt>`` instead of the default target.  Multiple targets may be
441   given, separated by spaces.
442
443 ``--config <cfg>``
444   For multi-configuration tools, choose configuration ``<cfg>``.
445
446 ``--clean-first``
447   Build target ``clean`` first, then build.
448   (To clean only, use ``--target clean``.)
449
450 ``--use-stderr``
451   Ignored.  Behavior is default in CMake >= 3.0.
452
453 ``--verbose, -v``
454   Enable verbose output - if supported - including the build commands to be
455   executed.
456
457   This option can be omitted if :envvar:`VERBOSE` environment variable or
458   :variable:`CMAKE_VERBOSE_MAKEFILE` cached variable is set.
459
460
461 ``--``
462   Pass remaining options to the native tool.
463
464 Run ``cmake --build`` with no options for quick help.
465
466 Install a Project
467 =================
468
469 CMake provides a command-line signature to install an already-generated
470 project binary tree:
471
472 .. code-block:: shell
473
474   cmake --install <dir> [<options>]
475
476 This may be used after building a project to run installation without
477 using the generated build system or the native build tool.
478 The options are:
479
480 ``--install <dir>``
481   Project binary directory to install. This is required and must be first.
482
483 ``--config <cfg>``
484   For multi-configuration generators, choose configuration ``<cfg>``.
485
486 ``--component <comp>``
487   Component-based install. Only install component ``<comp>``.
488
489 ``--default-directory-permissions <permissions>``
490   Default directory install permissions. Permissions in format ``<u=rwx,g=rx,o=rx>``.
491
492 ``--prefix <prefix>``
493   Override the installation prefix, :variable:`CMAKE_INSTALL_PREFIX`.
494
495 ``--strip``
496   Strip before installing.
497
498 ``-v, --verbose``
499   Enable verbose output.
500
501   This option can be omitted if :envvar:`VERBOSE` environment variable is set.
502
503 Run ``cmake --install`` with no options for quick help.
504
505 Open a Project
506 ==============
507
508 .. code-block:: shell
509
510   cmake --open <dir>
511
512 Open the generated project in the associated application.  This is only
513 supported by some generators.
514
515
516 .. _`Script Processing Mode`:
517
518 Run a Script
519 ============
520
521 .. code-block:: shell
522
523   cmake [{-D <var>=<value>}...] -P <cmake-script-file> [-- <unparsed-options>...]
524
525 Process the given cmake file as a script written in the CMake
526 language.  No configure or generate step is performed and the cache
527 is not modified.  If variables are defined using ``-D``, this must be
528 done before the ``-P`` argument.
529
530 Any options after ``--`` are not parsed by CMake, but they are still included
531 in the set of :variable:`CMAKE_ARGV<n> <CMAKE_ARGV0>` variables passed to the
532 script (including the ``--`` itself).
533
534
535 Run a Command-Line Tool
536 =======================
537
538 CMake provides builtin command-line tools through the signature
539
540 .. code-block:: shell
541
542   cmake -E <command> [<options>]
543
544 Run ``cmake -E`` or ``cmake -E help`` for a summary of commands.
545 Available commands are:
546
547 ``capabilities``
548   Report cmake capabilities in JSON format. The output is a JSON object
549   with the following keys:
550
551   ``version``
552     A JSON object with version information. Keys are:
553
554     ``string``
555       The full version string as displayed by cmake ``--version``.
556     ``major``
557       The major version number in integer form.
558     ``minor``
559       The minor version number in integer form.
560     ``patch``
561       The patch level in integer form.
562     ``suffix``
563       The cmake version suffix string.
564     ``isDirty``
565       A bool that is set if the cmake build is from a dirty tree.
566
567   ``generators``
568     A list available generators. Each generator is a JSON object with the
569     following keys:
570
571     ``name``
572       A string containing the name of the generator.
573     ``toolsetSupport``
574       ``true`` if the generator supports toolsets and ``false`` otherwise.
575     ``platformSupport``
576       ``true`` if the generator supports platforms and ``false`` otherwise.
577     ``extraGenerators``
578       A list of strings with all the extra generators compatible with
579       the generator.
580
581   ``fileApi``
582     Optional member that is present when the :manual:`cmake-file-api(7)`
583     is available.  The value is a JSON object with one member:
584
585     ``requests``
586       A JSON array containing zero or more supported file-api requests.
587       Each request is a JSON object with members:
588
589       ``kind``
590         Specifies one of the supported :ref:`file-api object kinds`.
591
592       ``version``
593         A JSON array whose elements are each a JSON object containing
594         ``major`` and ``minor`` members specifying non-negative integer
595         version components.
596
597   ``serverMode``
598     ``true`` if cmake supports server-mode and ``false`` otherwise.
599     Always false since CMake 3.20.
600
601 ``cat <files>...``
602   Concatenate files and print on the standard output.
603
604 ``chdir <dir> <cmd> [<arg>...]``
605   Change the current working directory and run a command.
606
607 ``compare_files [--ignore-eol] <file1> <file2>``
608   Check if ``<file1>`` is same as ``<file2>``. If files are the same,
609   then returns ``0``, if not it returns ``1``.  In case of invalid
610   arguments, it returns 2. The ``--ignore-eol`` option
611   implies line-wise comparison and ignores LF/CRLF differences.
612
613 ``copy <file>... <destination>``
614   Copy files to ``<destination>`` (either file or directory).
615   If multiple files are specified, the ``<destination>`` must be
616   directory and it must exist. Wildcards are not supported.
617   ``copy`` does follow symlinks. That means it does not copy symlinks,
618   but the files or directories it point to.
619
620 ``copy_directory <dir>... <destination>``
621   Copy content of ``<dir>...`` directories to ``<destination>`` directory.
622   If ``<destination>`` directory does not exist it will be created.
623   ``copy_directory`` does follow symlinks.
624
625 ``copy_if_different <file>... <destination>``
626   Copy files to ``<destination>`` (either file or directory) if
627   they have changed.
628   If multiple files are specified, the ``<destination>`` must be
629   directory and it must exist.
630   ``copy_if_different`` does follow symlinks.
631
632 ``create_symlink <old> <new>``
633   Create a symbolic link ``<new>`` naming ``<old>``.
634
635   .. note::
636     Path to where ``<new>`` symbolic link will be created has to exist beforehand.
637
638 ``create_hardlink <old> <new>``
639   Create a hard link ``<new>`` naming ``<old>``.
640
641   .. note::
642     Path to where ``<new>`` hard link will be created has to exist beforehand.
643     ``<old>`` has to exist beforehand.
644
645 ``echo [<string>...]``
646   Displays arguments as text.
647
648 ``echo_append [<string>...]``
649   Displays arguments as text but no new line.
650
651 ``env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...``
652   Run command in a modified environment.
653
654 ``environment``
655   Display the current environment variables.
656
657 ``false``
658   Do nothing, with an exit code of 1.
659
660 ``make_directory <dir>...``
661   Create ``<dir>`` directories.  If necessary, create parent
662   directories too.  If a directory already exists it will be
663   silently ignored.
664
665 ``md5sum <file>...``
666   Create MD5 checksum of files in ``md5sum`` compatible format::
667
668      351abe79cd3800b38cdfb25d45015a15  file1.txt
669      052f86c15bbde68af55c7f7b340ab639  file2.txt
670
671 ``sha1sum <file>...``
672   Create SHA1 checksum of files in ``sha1sum`` compatible format::
673
674      4bb7932a29e6f73c97bb9272f2bdc393122f86e0  file1.txt
675      1df4c8f318665f9a5f2ed38f55adadb7ef9f559c  file2.txt
676
677 ``sha224sum <file>...``
678   Create SHA224 checksum of files in ``sha224sum`` compatible format::
679
680      b9b9346bc8437bbda630b0b7ddfc5ea9ca157546dbbf4c613192f930  file1.txt
681      6dfbe55f4d2edc5fe5c9197bca51ceaaf824e48eba0cc453088aee24  file2.txt
682
683 ``sha256sum <file>...``
684   Create SHA256 checksum of files in ``sha256sum`` compatible format::
685
686      76713b23615d31680afeb0e9efe94d47d3d4229191198bb46d7485f9cb191acc  file1.txt
687      15b682ead6c12dedb1baf91231e1e89cfc7974b3787c1e2e01b986bffadae0ea  file2.txt
688
689 ``sha384sum <file>...``
690   Create SHA384 checksum of files in ``sha384sum`` compatible format::
691
692      acc049fedc091a22f5f2ce39a43b9057fd93c910e9afd76a6411a28a8f2b8a12c73d7129e292f94fc0329c309df49434  file1.txt
693      668ddeb108710d271ee21c0f3acbd6a7517e2b78f9181c6a2ff3b8943af92b0195dcb7cce48aa3e17893173c0a39e23d  file2.txt
694
695 ``sha512sum <file>...``
696   Create SHA512 checksum of files in ``sha512sum`` compatible format::
697
698      2a78d7a6c5328cfb1467c63beac8ff21794213901eaadafd48e7800289afbc08e5fb3e86aa31116c945ee3d7bf2a6194489ec6101051083d1108defc8e1dba89  file1.txt
699      7a0b54896fe5e70cca6dd643ad6f672614b189bf26f8153061c4d219474b05dad08c4e729af9f4b009f1a1a280cb625454bf587c690f4617c27e3aebdf3b7a2d  file2.txt
700
701 ``remove [-f] <file>...``
702   .. deprecated:: 3.17
703
704   Remove the file(s). The planned behaviour was that if any of the
705   listed files already do not exist, the command returns a non-zero exit code,
706   but no message is logged. The ``-f`` option changes the behavior to return a
707   zero exit code (i.e. success) in such situations instead.
708   ``remove`` does not follow symlinks. That means it remove only symlinks
709   and not files it point to.
710
711   The implementation was buggy and always returned 0. It cannot be fixed without
712   breaking backwards compatibility. Use ``rm`` instead.
713
714 ``remove_directory <dir>...``
715   .. deprecated:: 3.17
716
717   Remove ``<dir>`` directories and their contents. If a directory does
718   not exist it will be silently ignored.  If ``<dir>`` is a symlink to
719   a directory, just the symlink will be removed.
720   Use ``rm`` instead.
721
722 ``rename <oldname> <newname>``
723   Rename a file or directory (on one volume). If file with the ``<newname>`` name
724   already exists, then it will be silently replaced.
725
726 ``rm [-rRf] <file> <dir>...``
727   Remove the files ``<file>`` or directories ``dir``.
728   Use ``-r`` or ``-R`` to remove directories and their contents recursively.
729   If any of the listed files/directories do not exist, the command returns a
730   non-zero exit code, but no message is logged. The ``-f`` option changes
731   the behavior to return a zero exit code (i.e. success) in such
732   situations instead.
733
734 ``server``
735   Launch :manual:`cmake-server(7)` mode.
736
737 ``sleep <number>...``
738   Sleep for given number of seconds.
739
740 ``tar [cxt][vf][zjJ] file.tar [<options>] [--] [<pathname>...]``
741   Create or extract a tar or zip archive.  Options are:
742
743   ``c``
744     Create a new archive containing the specified files.
745     If used, the ``<pathname>...`` argument is mandatory.
746   ``x``
747     Extract to disk from the archive.
748     The ``<pathname>...`` argument could be used to extract only selected files
749     or directories.
750     When extracting selected files or directories, you must provide their exact
751     names including the path, as printed by list (``-t``).
752   ``t``
753     List archive contents.
754     The ``<pathname>...`` argument could be used to list only selected files
755     or directories.
756   ``v``
757     Produce verbose output.
758   ``z``
759     Compress the resulting archive with gzip.
760   ``j``
761     Compress the resulting archive with bzip2.
762   ``J``
763     Compress the resulting archive with XZ.
764   ``--zstd``
765     Compress the resulting archive with Zstandard.
766   ``--files-from=<file>``
767     Read file names from the given file, one per line.
768     Blank lines are ignored.  Lines may not start in ``-``
769     except for ``--add-file=<name>`` to add files whose
770     names start in ``-``.
771   ``--format=<format>``
772     Specify the format of the archive to be created.
773     Supported formats are: ``7zip``, ``gnutar``, ``pax``,
774     ``paxr`` (restricted pax, default), and ``zip``.
775   ``--mtime=<date>``
776     Specify modification time recorded in tarball entries.
777   ``--``
778     Stop interpreting options and treat all remaining arguments
779     as file names, even if they start with ``-``.
780
781
782 ``time <command> [<args>...]``
783   Run command and display elapsed time.
784
785 ``touch <file>...``
786   Creates ``<file>`` if file do not exist.
787   If ``<file>`` exists, it is changing ``<file>`` access and modification times.
788
789 ``touch_nocreate <file>...``
790   Touch a file if it exists but do not create it.  If a file does
791   not exist it will be silently ignored.
792
793 ``true``
794   Do nothing, with an exit code of 0.
795
796 Windows-specific Command-Line Tools
797 -----------------------------------
798
799 The following ``cmake -E`` commands are available only on Windows:
800
801 ``delete_regv <key>``
802   Delete Windows registry value.
803
804 ``env_vs8_wince <sdkname>``
805   Displays a batch file which sets the environment for the provided
806   Windows CE SDK installed in VS2005.
807
808 ``env_vs9_wince <sdkname>``
809   Displays a batch file which sets the environment for the provided
810   Windows CE SDK installed in VS2008.
811
812 ``write_regv <key> <value>``
813   Write Windows registry value.
814
815
816 Run the Find-Package Tool
817 =========================
818
819 CMake provides a pkg-config like helper for Makefile-based projects:
820
821 .. code-block:: shell
822
823   cmake --find-package [<options>]
824
825 It searches a package using :command:`find_package()` and prints the
826 resulting flags to stdout.  This can be used instead of pkg-config
827 to find installed libraries in plain Makefile-based projects or in
828 autoconf-based projects (via ``share/aclocal/cmake.m4``).
829
830 .. note::
831   This mode is not well-supported due to some technical limitations.
832   It is kept for compatibility but should not be used in new projects.
833
834
835 View Help
836 =========
837
838 To print selected pages from the CMake documentation, use
839
840 .. code-block:: shell
841
842   cmake --help[-<topic>]
843
844 with one of the following options:
845
846 .. include:: OPTIONS_HELP.txt
847
848 To view the presets available for a project, use
849
850 .. code-block:: shell
851
852   cmake <source-dir> --list-presets
853
854 See Also
855 ========
856
857 .. include:: LINKS.txt