1CMAKE(1)                             CMake                            CMAKE(1)
2
3
4

NAME

6       cmake - CMake Command-Line Reference
7

SYNOPSIS

9          Generate a Project Buildsystem
10           cmake [<options>] <path-to-source | path-to-existing-build>
11           cmake [<options>] -S <path-to-source> -B <path-to-build>
12
13          Build a Project
14           cmake --build <dir> [<options>] [-- <build-tool-options>]
15
16          Install a Project
17           cmake --install <dir> [<options>]
18
19          Open a Project
20           cmake --open <dir>
21
22          Run a Script
23           cmake [-D <var>=<value>]... -P <cmake-script-file>
24
25          Run a Command-Line Tool
26           cmake -E <command> [<options>]
27
28          Run the Find-Package Tool
29           cmake --find-package [<options>]
30
31          Run a Workflow Preset
32           cmake --workflow [<options>]
33
34          View Help
35           cmake --help[-<topic>]
36

DESCRIPTION

38       The  cmake  executable is the command-line interface of the cross-plat‐
39       form buildsystem generator CMake.  The above Synopsis lists various ac‐
40       tions the tool can perform as described in sections below.
41
42       To build a software project with CMake, Generate a Project Buildsystem.
43       Optionally use cmake to Build a Project, Install a Project or just  run
44       the  corresponding  build tool (e.g. make) directly.  cmake can also be
45       used to View Help.
46
47       The other actions are meant for  use  by  software  developers  writing
48       scripts in the CMake language to support their builds.
49
50       For  graphical  user interfaces that may be used in place of cmake, see
51       ccmake and cmake-gui.  For command-line interfaces to the CMake testing
52       and packaging facilities, see ctest and cpack.
53
54       For  more  information on CMake at large, see also the links at the end
55       of this manual.
56

INTRODUCTION TO CMAKE BUILDSYSTEMS

58       A buildsystem describes how to build a project's  executables  and  li‐
59       braries  from  its  source  code  using  a  build  tool to automate the
60       process.  For example, a buildsystem may be a Makefile for use  with  a
61       command-line  make tool or a project file for an Integrated Development
62       Environment  (IDE).   In  order  to  avoid  maintaining  multiple  such
63       buildsystems,  a  project  may specify its buildsystem abstractly using
64       files written in the CMake language.  From these files CMake  generates
65       a  preferred buildsystem locally for each user through a backend called
66       a generator.
67
68       To generate a buildsystem with CMake, the following must be selected:
69
70       Source Tree
71              The top-level directory containing source files provided by  the
72              project.   The  project specifies its buildsystem using files as
73              described in  the  cmake-language(7)  manual,  starting  with  a
74              top-level  file named CMakeLists.txt.  These files specify build
75              targets   and   their   dependencies   as   described   in   the
76              cmake-buildsystem(7) manual.
77
78       Build Tree
79              The  top-level  directory  in  which buildsystem files and build
80              output artifacts (e.g. executables  and  libraries)  are  to  be
81              stored.   CMake will write a CMakeCache.txt file to identify the
82              directory as a build tree and store persistent information  such
83              as buildsystem configuration options.
84
85              To  maintain  a  pristine  source tree, perform an out-of-source
86              build by using a separate dedicated build  tree.   An  in-source
87              build in which the build tree is placed in the same directory as
88              the source tree is also supported, but discouraged.
89
90       Generator
91              This chooses the kind  of  buildsystem  to  generate.   See  the
92              cmake-generators(7)  manual for documentation of all generators.
93              Run cmake --help to see a list of generators available  locally.
94              Optionally  use  the  -G option below to specify a generator, or
95              simply accept the default CMake chooses for  the  current  plat‐
96              form.
97
98              When  using  one of the Command-Line Build Tool Generators CMake
99              expects that the environment needed by the compiler toolchain is
100              already  configured  in  the  shell.   When using one of the IDE
101              Build Tool Generators, no particular environment is needed.
102

GENERATE A PROJECT BUILDSYSTEM

104       Run CMake with one of the following command signatures to  specify  the
105       source and build trees and generate a buildsystem:
106
107       cmake [<options>] <path-to-source>
108              Uses  the  current  working  directory  as  the  build tree, and
109              <path-to-source> as the source tree.  The specified path may  be
110              absolute  or  relative  to  the  current working directory.  The
111              source tree must contain a CMakeLists.txt file and must not con‐
112              tain  a CMakeCache.txt file because the latter identifies an ex‐
113              isting build tree.  For example:
114
115                 $ mkdir build ; cd build
116                 $ cmake ../src
117
118       cmake [<options>] <path-to-existing-build>
119              Uses <path-to-existing-build> as the build tree, and  loads  the
120              path to the source tree from its CMakeCache.txt file, which must
121              have already been generated by a previous  run  of  CMake.   The
122              specified  path may be absolute or relative to the current work‐
123              ing directory.  For example:
124
125                 $ cd build
126                 $ cmake .
127
128       cmake [<options>] -S <path-to-source> -B <path-to-build>
129          New in version 3.13.
130
131
132          Uses <path-to-build> as the build tree and <path-to-source>  as  the
133          source tree.  The specified paths may be absolute or relative to the
134          current working directory.  The source tree must  contain  a  CMake‐
135          Lists.txt  file.  The build tree will be created automatically if it
136          does not already exist.  For example:
137
138              $ cmake -S src -B build
139
140       In all cases the <options> may be zero or more of the Options below.
141
142       The above styles for specifying the  source  and  build  trees  may  be
143       mixed.   Paths  specified with -S or -B are always classified as source
144       or build trees, respectively.  Paths specified with plain arguments are
145       classified based on their content and the types of paths given earlier.
146       If only one type of path is given, the current working directory  (cwd)
147       is used for the other.  For example:
148
149                   ┌────────────────────┬────────────┬───────────┐
150                   │Command Line        │ Source Dir │ Build Dir │
151                   ├────────────────────┼────────────┼───────────┤
152cmake src           src        cwd
153                   ├────────────────────┼────────────┼───────────┤
154cmake build (exist‐ │ loadedbuild     
155                   │ing)                │            │           │
156                   ├────────────────────┼────────────┼───────────┤
157cmake -S src        src        cwd
158                   ├────────────────────┼────────────┼───────────┤
159cmake -S src build  src        build     
160                   ├────────────────────┼────────────┼───────────┤
161cmake  -S  src   -B src        build     
162build               │            │           │
163                   ├────────────────────┼────────────┼───────────┤
164cmake -B build      cwdbuild     
165                   ├────────────────────┼────────────┼───────────┤
166cmake -B build src  src        build     
167                   ├────────────────────┼────────────┼───────────┤
168cmake  -B  build -S src        build     
169src                 │            │           │
170                   └────────────────────┴────────────┴───────────┘
171
172       Changed in version 3.23: CMake warns when  multiple  source  paths  are
173       specified.  This has never been officially documented or supported, but
174       older versions accidentally accepted multiple source paths and used the
175       last path specified.  Avoid passing multiple source path arguments.
176
177
178       After  generating  a  buildsystem  one may use the corresponding native
179       build tool to build the project.  For example,  after  using  the  Unix
180       Makefiles generator one may run make directly:
181
182              $ make
183              $ make install
184
185       Alternatively,  one  may  use cmake to Build a Project by automatically
186       choosing and invoking the appropriate native build tool.
187
188   Options
189       -S <path-to-source>
190              Path to root directory of the CMake project to build.
191
192       -B <path-to-build>
193              Path to directory which CMake will use as the root of build  di‐
194              rectory.
195
196              If the directory doesn't already exist CMake will make it.
197
198       -C <initial-cache>
199              Pre-load a script to populate the cache.
200
201              When  CMake  is  first  run in an empty build tree, it creates a
202              CMakeCache.txt file and populates it with customizable  settings
203              for the project.  This option may be used to specify a file from
204              which to load cache entries before the first  pass  through  the
205              project's  CMake  listfiles.   The  loaded entries take priority
206              over the project's default values.  The given file should  be  a
207              CMake  script  containing  set() commands that use the CACHE op‐
208              tion, not a cache-format file.
209
210              References to CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR  within  the
211              script evaluate to the top-level source and build tree.
212
213       -D <var>:<type>=<value>, -D <var>=<value>
214              Create or update a CMake CACHE entry.
215
216              When  CMake  is  first  run in an empty build tree, it creates a
217              CMakeCache.txt file and populates it with customizable  settings
218              for  the  project.  This option may be used to specify a setting
219              that takes priority over the project's default value.   The  op‐
220              tion may be repeated for as many CACHE entries as desired.
221
222              If  the  :<type>  portion  is  given it must be one of the types
223              specified by the set() command documentation for its CACHE  sig‐
224              nature.   If  the  :<type>  portion is omitted the entry will be
225              created with no type if it does not exist with a  type  already.
226              If  a  command  in the project sets the type to PATH or FILEPATH
227              then the <value> will be converted to an absolute path.
228
229              This  option  may  also  be  given   as   a   single   argument:
230              -D<var>:<type>=<value> or -D<var>=<value>.
231
232              It's  important to note that the order of -C and -D arguments is
233              significant. They will be carried out  in  the  order  they  are
234              listed, with the last argument taking precedence over the previ‐
235              ous ones. For example, if you specify  -DCMAKE_BUILD_TYPE=Debug,
236              followed by a -C argument with a file that calls:
237
238                 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
239
240              then  the -C argument will take precedence, and CMAKE_BUILD_TYPE
241              will be set to Release. However, if the -D argument comes  after
242              the -C argument, it will be set to Debug.
243
244              If  a set(... CACHE ...) call in the -C file does not use FORCE,
245              and a -D argument sets the same variable, the -D  argument  will
246              take  precedence  regardless  of  order because of the nature of
247              non-FORCE set(... CACHE ...) calls.
248
249       -U <globbing_expr>
250              Remove matching entries from CMake CACHE.
251
252              This option may be used to remove one or more variables from the
253              CMakeCache.txt file, globbing expressions using * and ? are sup‐
254              ported.  The option may be repeated for as many CACHE entries as
255              desired.
256
257              Use with care, you can make your CMakeCache.txt non-working.
258
259       -G <generator-name>
260              Specify a build system generator.
261
262              CMake may support multiple native build systems on certain plat‐
263              forms.  A generator is responsible for generating  a  particular
264              build  system.   Possible  generator  names are specified in the
265              cmake-generators(7) manual.
266
267              If not specified, CMake checks the  CMAKE_GENERATOR  environment
268              variable  and  otherwise  falls back to a builtin default selec‐
269              tion.
270
271       -T <toolset-spec>
272              Toolset specification for the generator, if supported.
273
274              Some CMake generators support a toolset  specification  to  tell
275              the  native  build  system  how  to  choose a compiler.  See the
276              CMAKE_GENERATOR_TOOLSET variable for details.
277
278       -A <platform-name>
279              Specify platform name if supported by generator.
280
281              Some CMake generators support a platform name to be given to the
282              native  build  system  to  choose  a  compiler  or SDK.  See the
283              CMAKE_GENERATOR_PLATFORM variable for details.
284
285       --toolchain <path-to-file>
286              Specify the cross compiling toolchain file, equivalent  to  set‐
287              ting CMAKE_TOOLCHAIN_FILE variable.
288
289       --install-prefix <directory>
290              Specify    the    installation    directory,    used    by   the
291              CMAKE_INSTALL_PREFIX variable. Must be an absolute path.
292
293       -Wno-dev
294              Suppress developer warnings.
295
296              Suppress warnings that are meant for the author  of  the  CMake‐
297              Lists.txt  files. By default this will also turn off deprecation
298              warnings.
299
300       -Wdev  Enable developer warnings.
301
302              Enable warnings that are meant for  the  author  of  the  CMake‐
303              Lists.txt  files.  By default this will also turn on deprecation
304              warnings.
305
306       -Wdeprecated
307              Enable deprecated functionality warnings.
308
309              Enable warnings for usage of deprecated functionality, that  are
310              meant for the author of the CMakeLists.txt files.
311
312       -Wno-deprecated
313              Suppress deprecated functionality warnings.
314
315              Suppress  warnings  for  usage of deprecated functionality, that
316              are meant for the author of the CMakeLists.txt files.
317
318       -Werror=<what>
319              Treat CMake warnings as errors. <what> must be one of  the  fol‐
320              lowing:
321
322              dev    Make developer warnings errors.
323
324                     Make warnings that are meant for the author of the CMake‐
325                     Lists.txt files errors. By default this will also turn on
326                     deprecated warnings as errors.
327
328              deprecated
329                     Make deprecated macro and function warnings errors.
330
331                     Make  warnings  for  usage of deprecated macros and func‐
332                     tions, that are  meant  for  the  author  of  the  CMake‐
333                     Lists.txt files, errors.
334
335       -Wno-error=<what>
336              Do not treat CMake warnings as errors. <what> must be one of the
337              following:
338
339              dev    Make warnings that are meant for the author of the CMake‐
340                     Lists.txt  files  not  errors.  By default this will also
341                     turn off deprecated warnings as errors.
342
343              deprecated
344                     Make warnings for usage of deprecated  macros  and  func‐
345                     tions,  that  are  meant  for  the  author  of the CMake‐
346                     Lists.txt files, not errors.
347
348       --fresh
349              New in version 3.24.
350
351
352              Perform a fresh configuration of the build tree.   This  removes
353              any  existing CMakeCache.txt file and associated CMakeFiles/ di‐
354              rectory, and recreates them from scratch.
355
356       -L[A][H]
357              List non-advanced cached variables.
358
359              List CACHE variables will run CMake and list all  the  variables
360              from  the  CMake  CACHE  that  are  not  marked  as  INTERNAL or
361              ADVANCED.  This will effectively display current CMake settings,
362              which  can then be changed with -D option.  Changing some of the
363              variables may result in more variables being created.  If  A  is
364              specified,  then  it will display also advanced variables.  If H
365              is specified, it will also display help for each variable.
366
367       -N     View mode only.
368
369              Only load the cache.  Do not actually run configure and generate
370              steps.
371
372       --graphviz=<file>
373              Generate  graphviz of dependencies, see CMakeGraphVizOptions for
374              more.
375
376              Generate a graphviz input file that will contain all the library
377              and  executable dependencies in the project.  See the documenta‐
378              tion for CMakeGraphVizOptions for more details.
379
380       --system-information [file]
381              Dump information about this system.
382
383              Dump a wide range of information about the current  system.   If
384              run  from  the  top of a binary tree for a CMake project it will
385              dump additional information such as the cache, log files etc.
386
387       --log-level=<level>
388              Set the log <level>.
389
390              The message() command will only output messages of the specified
391              log  level  or higher.  The valid log levels are ERROR, WARNING,
392              NOTICE, STATUS (default), VERBOSE, DEBUG, or TRACE.
393
394              To  make  a  log  level  persist   between   CMake   runs,   set
395              CMAKE_MESSAGE_LOG_LEVEL  as  a  cache variable instead.  If both
396              the command line option and the variable are given, the  command
397              line option takes precedence.
398
399              For  backward compatibility reasons, --loglevel is also accepted
400              as a synonym for this option.
401
402              New in version 3.25: See the cmake_language() command for a  way
403              to query the current message logging level.
404
405
406       --log-context
407              Enable the message() command outputting context attached to each
408              message.
409
410              This option turns on showing context for the current  CMake  run
411              only.  To make showing the context persistent for all subsequent
412              CMake runs, set CMAKE_MESSAGE_CONTEXT_SHOW as a  cache  variable
413              instead.     When   this   command   line   option   is   given,
414              CMAKE_MESSAGE_CONTEXT_SHOW is ignored.
415
416       --debug-trycompile
417              Do  not  delete  the   files   and   directories   created   for
418              try_compile()  /  try_run()  calls.  This is useful in debugging
419              failed checks.
420
421              Note that some uses of try_compile()  may  use  the  same  build
422              tree,  which  will  limit  the  usefulness  of  this option if a
423              project executes more than one try_compile().  For example, such
424              uses may change results as artifacts from a previous try-compile
425              may cause a different test to either pass or  fail  incorrectly.
426              This option is best used only when debugging.
427
428              (With  respect to the preceding, the try_run() command is effec‐
429              tively a try_compile().  Any combination of the two  is  subject
430              to the potential issues described.)
431
432              New in version 3.25: When this option is enabled, every try-com‐
433              pile check prints a log message reporting the directory in which
434              the check is performed.
435
436
437       --debug-output
438              Put cmake in a debug mode.
439
440              Print  extra  information during the cmake run like stack traces
441              with message(SEND_ERROR) calls.
442
443       --debug-find
444              Put cmake find commands in a debug mode.
445
446              Print extra find call information during the cmake run to  stan‐
447              dard error. Output is designed for human consumption and not for
448              parsing.  See also the CMAKE_FIND_DEBUG_MODE variable for debug‐
449              ging a more local part of the project.
450
451       --debug-find-pkg=<pkg>[,...]
452              Put cmake find commands in a debug mode when running under calls
453              to find_package(<pkg>), where <pkg> is an  entry  in  the  given
454              comma-separated list of case-sensitive package names.
455
456              Like --debug-find, but limiting scope to the specified packages.
457
458       --debug-find-var=<var>[,...]
459              Put  cmake  find commands in a debug mode when called with <var>
460              as the result variable, where <var> is an  entry  in  the  given
461              comma-separated list.
462
463              Like  --debug-find, but limiting scope to the specified variable
464              names.
465
466       --trace
467              Put cmake in trace mode.
468
469              Print a trace of all calls made and from where.
470
471       --trace-expand
472              Put cmake in trace mode.
473
474              Like --trace, but with variables expanded.
475
476       --trace-format=<format>
477              Put cmake in trace mode and sets the trace output format.
478
479              <format> can be one of the following values.
480
481                 human  Prints each trace line  in  a  human-readable  format.
482                        This is the default format.
483
484                 json-v1
485                        Prints  each  line  as  a separate JSON document. Each
486                        document is separated by a newline ( \n ). It is guar‐
487                        anteed  that no newline characters will be present in‐
488                        side a JSON document.
489
490                        JSON trace format:
491
492                            {
493                              "file": "/full/path/to/the/CMake/file.txt",
494                              "line": 0,
495                              "cmd": "add_executable",
496                              "args": ["foo", "bar"],
497                              "time": 1579512535.9687231,
498                              "frame": 2,
499                              "global_frame": 4
500                            }
501
502                        The members are:
503
504                        file   The full path to the CMake  source  file  where
505                               the function was called.
506
507                        line   The  line  in  file where the function call be‐
508                               gins.
509
510                        line_end
511                               If the function call spans multiple lines, this
512                               field  will  be set to the line where the func‐
513                               tion call ends. If the function calls  spans  a
514                               single  line,  this  field  will be unset. This
515                               field was added  in  minor  version  2  of  the
516                               json-v1 format.
517
518                        defer  Optional  member that is present when the func‐
519                               tion      call      was       deferred       by
520                               cmake_language(DEFER).   If  present, its value
521                               is a string containing the deferred call <id>.
522
523                        cmd    The name of the function that was called.
524
525                        args   A string list of all function parameters.
526
527                        time   Timestamp (seconds since epoch) of the function
528                               call.
529
530                        frame  Stack  frame  depth  of  the  function that was
531                               called,  within  the  context  of  the   CMake‐
532                               Lists.txt being processed currently.
533
534                        global_frame
535                               Stack  frame  depth  of  the  function that was
536                               called,  tracked  globally  across  all  CMake‐
537                               Lists.txt  files  involved  in  the trace. This
538                               field was added  in  minor  version  2  of  the
539                               json-v1 format.
540
541                        Additionally,  the  first JSON document outputted con‐
542                        tains the version key for the current major and  minor
543                        version of the
544
545                        JSON trace format:
546
547                            {
548                              "version": {
549                                "major": 1,
550                                "minor": 2
551                              }
552                            }
553
554                        The members are:
555
556                        version
557                               Indicates  the  version of the JSON format. The
558                               version has a major and minor  components  fol‐
559                               lowing semantic version conventions.
560
561       --trace-source=<file>
562              Put  cmake  in  trace mode, but output only lines of a specified
563              file.
564
565              Multiple options are allowed.
566
567       --trace-redirect=<file>
568              Put cmake in trace mode and redirect trace output to a file  in‐
569              stead of stderr.
570
571       --warn-uninitialized
572              Warn about uninitialized values.
573
574              Print a warning when an uninitialized variable is used.
575
576       --warn-unused-vars
577              Does  nothing.   In  CMake  versions  3.2 and below this enabled
578              warnings about unused variables.  In CMake versions 3.3  through
579              3.18  the option was broken.  In CMake 3.19 and above the option
580              has been removed.
581
582       --no-warn-unused-cli
583              Don't warn about command line options.
584
585              Don't find variables that are declared on the command line,  but
586              not used.
587
588       --check-system-vars
589              Find problems with variable usage in system files.
590
591              Normally,  unused  and  uninitialized variables are searched for
592              only in CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR.  This flag  tells
593              CMake to warn about other files as well.
594
595       --compile-no-warning-as-error
596              Ignore  target  property  COMPILE_WARNING_AS_ERROR  and variable
597              CMAKE_COMPILE_WARNING_AS_ERROR, preventing warnings  from  being
598              treated as errors on compile.
599
600       --profiling-output=<path>
601              Used in conjunction with --profiling-format to output to a given
602              path.
603
604       --profiling-format=<file>
605              Enable the output of profiling data of CMake script in the given
606              format.
607
608              This  can  aid  performance  analysis of CMake scripts executed.
609              Third party applications should be used to  process  the  output
610              into human readable format.
611
612              Currently  supported  values are: google-trace Outputs in Google
613              Trace Format, which can be parsed by the  about:tracing  tab  of
614              Google Chrome or using a plugin for a tool like Trace Compass.
615
616       --preset <preset>, --preset=<preset>
617              Reads   a  preset  from  <path-to-source>/CMakePresets.json  and
618              <path-to-source>/CMakeUserPresets.json. The preset  may  specify
619              the  generator  and the build directory, and a list of variables
620              and other arguments to pass to CMake. The current working direc‐
621              tory  must  contain  CMake  preset files. The CMake GUI can also
622              recognize CMakePresets.json and CMakeUserPresets.json files. For
623              full details on these files, see cmake-presets(7).
624
625              The  presets are read before all other command line options. The
626              options specified by the preset (variables, generator, etc.) can
627              all  be  overridden  by  manually specifying them on the command
628              line. For example, if the preset sets a variable called MYVAR to
629              1,  but the user sets it to 2 with a -D argument, the value 2 is
630              preferred.
631
632       --list-presets[=<type>]
633              Lists the available presets of the specified <type>.  Valid val‐
634              ues  for <type> are configure, build, test, package, or all.  If
635              <type> is omitted, configure is assumed.   The  current  working
636              directory must contain CMake preset files.
637

BUILD A PROJECT

639       CMake  provides  a command-line signature to build an already-generated
640       project binary tree:
641
642          cmake --build <dir>             [<options>] [-- <build-tool-options>]
643          cmake --build --preset <preset> [<options>] [-- <build-tool-options>]
644
645       This abstracts a native build tool's command-line  interface  with  the
646       following options:
647
648       --build <dir>
649              Project  binary directory to be built.  This is required (unless
650              a preset is specified) and must be first.
651
652       --preset <preset>, --preset=<preset>
653              Use a build preset to specify build options. The project  binary
654              directory  is inferred from the configurePreset key. The current
655              working directory must contain CMake preset files.   See  preset
656              for more details.
657
658       --list-presets
659              Lists the available build presets. The current working directory
660              must contain CMake preset files.
661
662       -j [<jobs>], --parallel [<jobs>]
663              New in version 3.12.
664
665
666              The maximum number of concurrent processes to use when building.
667              If  <jobs>  is omitted the native build tool's default number is
668              used.
669
670              The CMAKE_BUILD_PARALLEL_LEVEL  environment  variable,  if  set,
671              specifies  a  default  parallel  level  when  this option is not
672              given.
673
674              Some native build tools always build in parallel.   The  use  of
675              <jobs> value of 1 can be used to limit to a single job.
676
677       -t <tgt>..., --target <tgt>...
678              Build <tgt> instead of the default target.  Multiple targets may
679              be given, separated by spaces.
680
681       --config <cfg>
682              For multi-configuration tools, choose configuration <cfg>.
683
684       --clean-first
685              Build target clean first,  then  build.   (To  clean  only,  use
686              --target clean.)
687
688       --resolve-package-references=<value>
689              New in version 3.23.
690
691
692              Resolve remote package references from external package managers
693              (e.g. NuGet) before build. When <value> is set to on  (default),
694              packages  will  be  restored  before  building  a  target.  When
695              <value> is set to only, the packages will be  restored,  but  no
696              build  will  be performed.  When <value> is set to off, no pack‐
697              ages will be restored.
698
699              If the target does not define any package references,  this  op‐
700              tion does nothing.
701
702              This  setting  can  be  specified  in  a build preset (using re‐
703              solvePackageReferences). The preset setting will be ignored,  if
704              this command line option is specified.
705
706              If  no  command line parameter or preset option are provided, an
707              environment- specific cache variable will be  evaluated  to  de‐
708              cide, if package restoration should be performed.
709
710              When  using  the Visual Studio generator, package references are
711              defined using the VS_PACKAGE_REFERENCES property. Package refer‐
712              ences  are  restored  using NuGet. It can be disabled by setting
713              the CMAKE_VS_NUGET_PACKAGE_RESTORE variable to OFF.
714
715       --use-stderr
716              Ignored.  Behavior is default in CMake >= 3.0.
717
718       -v, --verbose
719              Enable verbose output - if supported - including the build  com‐
720              mands to be executed.
721
722              This  option  can  be omitted if VERBOSE environment variable or
723              CMAKE_VERBOSE_MAKEFILE cached variable is set.
724
725       --     Pass remaining options to the native tool.
726
727       Run cmake --build with no options for quick help.
728

INSTALL A PROJECT

730       CMake provides a command-line signature to install an already-generated
731       project binary tree:
732
733          cmake --install <dir> [<options>]
734
735       This  may  be used after building a project to run installation without
736       using the generated build system or the native build tool.  The options
737       are:
738
739       --install <dir>
740              Project  binary  directory to install. This is required and must
741              be first.
742
743       --config <cfg>
744              For multi-configuration generators, choose configuration <cfg>.
745
746       --component <comp>
747              Component-based install. Only install component <comp>.
748
749       --default-directory-permissions <permissions>
750              Default directory install  permissions.  Permissions  in  format
751              <u=rwx,g=rx,o=rx>.
752
753       --prefix <prefix>
754              Override the installation prefix, CMAKE_INSTALL_PREFIX.
755
756       --strip
757              Strip before installing.
758
759       -v, --verbose
760              Enable verbose output.
761
762              This  option  can  be omitted if VERBOSE environment variable is
763              set.
764
765       Run cmake --install with no options for quick help.
766

OPEN A PROJECT

768          cmake --open <dir>
769
770       Open the generated project in the associated application.  This is only
771       supported by some generators.
772

RUN A SCRIPT

774          cmake [-D <var>=<value>]... -P <cmake-script-file> [-- <unparsed-options>...]
775
776       -D <var>=<value>
777              Define a variable for script mode.
778
779       -P <cmake-script-file>
780              Process  the  given  cmake file as a script written in the CMake
781              language.  No configure or generate step is  performed  and  the
782              cache  is not modified.  If variables are defined using -D, this
783              must be done before the -P argument.
784
785       Any options after -- are not parsed by CMake, but they  are  still  in‐
786       cluded  in the set of CMAKE_ARGV<n> variables passed to the script (in‐
787       cluding the -- itself).
788

RUN A COMMAND-LINE TOOL

790       CMake provides builtin command-line tools through the signature
791
792          cmake -E <command> [<options>]
793
794       -E [help]
795              Run cmake -E or cmake -E help for a summary of commands.
796
797       Available commands are:
798
799       capabilities
800              New in version 3.7.
801
802
803              Report cmake capabilities in JSON format. The output is  a  JSON
804              object with the following keys:
805
806              version
807                     A JSON object with version information. Keys are:
808
809                     string The  full  version  string  as  displayed by cmake
810                            --version.
811
812                     major  The major version number in integer form.
813
814                     minor  The minor version number in integer form.
815
816                     patch  The patch level in integer form.
817
818                     suffix The cmake version suffix string.
819
820                     isDirty
821                            A bool that is set if the cmake build  is  from  a
822                            dirty tree.
823
824              generators
825                     A list available generators. Each generator is a JSON ob‐
826                     ject with the following keys:
827
828                     name   A string containing the name of the generator.
829
830                     toolsetSupport
831                            true if the generator supports toolsets and  false
832                            otherwise.
833
834                     platformSupport
835                            true if the generator supports platforms and false
836                            otherwise.
837
838                     supportedPlatforms
839                            New in version 3.21.
840
841
842                            Optional member that may be present when the  gen‐
843                            erator   supports   platform   specification   via
844                            CMAKE_GENERATOR_PLATFORM (-A ...).  The value is a
845                            list of platforms known to be supported.
846
847                     extraGenerators
848                            A  list  of  strings with all the extra generators
849                            compatible with the generator.
850
851              fileApi
852                     Optional   member    that    is    present    when    the
853                     cmake-file-api(7)  is available.  The value is a JSON ob‐
854                     ject with one member:
855
856                     requests
857                            A JSON array containing  zero  or  more  supported
858                            file-api  requests.  Each request is a JSON object
859                            with members:
860
861                            kind   Specifies  one  of  the  supported   Object
862                                   Kinds.
863
864                            version
865                                   A JSON array whose elements are each a JSON
866                                   object containing major and  minor  members
867                                   specifying   non-negative  integer  version
868                                   components.
869
870              serverMode
871                     true if cmake supports server-mode and  false  otherwise.
872                     Always false since CMake 3.20.
873
874              tls    New in version 3.25.
875
876
877                     true if TLS support is enabled and false otherwise.
878
879       cat [--] <files>...
880              New in version 3.18.
881
882
883              Concatenate files and print on the standard output.
884
885              --     New in version 3.24.
886
887
888                     Added support for the double dash argument --. This basic
889                     implementation of cat does not support  any  options,  so
890                     using  a  option starting with - will result in an error.
891                     Use -- to indicate the end of options,  in  case  a  file
892                     starts with -.
893
894       chdir <dir> <cmd> [<arg>...]
895              Change the current working directory and run a command.
896
897       compare_files [--ignore-eol] <file1> <file2>
898              Check if <file1> is same as <file2>. If files are the same, then
899              returns 0, if not it returns 1.  In case of  invalid  arguments,
900              it returns 2.
901
902              --ignore-eol
903                     New in version 3.14.
904
905
906                     The  option  implies  line-wise  comparison  and  ignores
907                     LF/CRLF differences.
908
909       copy <file>... <destination>
910              Copy files to <destination> (either file or directory).  If mul‐
911              tiple  files  are specified, the <destination> must be directory
912              and it must exist. Wildcards are not supported.  copy does  fol‐
913              low  symlinks.  That  means  it  does not copy symlinks, but the
914              files or directories it point to.
915
916              New in version 3.5: Support for multiple input files.
917
918
919       copy_directory <dir>... <destination>
920              Copy content of <dir>... directories to <destination> directory.
921              If  <destination>  directory  does not exist it will be created.
922              copy_directory does follow symlinks.
923
924              New in version 3.5: Support for multiple input directories.
925
926
927              New in version 3.15: The command now fails when the  source  di‐
928              rectory  does not exist.  Previously it succeeded by creating an
929              empty destination directory.
930
931
932       copy_if_different <file>... <destination>
933              Copy files to <destination> (either file or directory)  if  they
934              have  changed.   If  multiple files are specified, the <destina‐
935              tion> must be directory and it  must  exist.   copy_if_different
936              does follow symlinks.
937
938              New in version 3.5: Support for multiple input files.
939
940
941       create_symlink <old> <new>
942              Create a symbolic link <new> naming <old>.
943
944              New in version 3.13: Support for creating symlinks on Windows.
945
946
947              NOTE:
948                 Path  to where <new> symbolic link will be created has to ex‐
949                 ist beforehand.
950
951       create_hardlink <old> <new>
952              New in version 3.19.
953
954
955              Create a hard link <new> naming <old>.
956
957              NOTE:
958                 Path to where <new> hard link will be created  has  to  exist
959                 beforehand.  <old> has to exist beforehand.
960
961       echo [<string>...]
962              Displays arguments as text.
963
964       echo_append [<string>...]
965              Displays arguments as text but no new line.
966
967       env [<options>] [--] <command> [<arg>...]
968              New in version 3.1.
969
970
971              Run command in a modified environment. Options are:
972
973              NAME=VALUE
974                     Replaces the current value of NAME with VALUE.
975
976              --unset=NAME
977                     Unsets the current value of NAME.
978
979              --modify ENVIRONMENT_MODIFICATION
980                     New in version 3.25.
981
982
983                     Apply  a single ENVIRONMENT_MODIFICATION operation to the
984                     modified environment.
985
986                     The NAME=VALUE and --unset=NAME options are equivalent to
987                     --modify NAME=set:VALUE and --modify NAME=unset:, respec‐
988                     tively.  Note that --modify NAME=reset:  resets  NAME  to
989                     the  value it had when cmake launched (or unsets it), not
990                     to the most recent NAME=VALUE option.
991
992              --     New in version 3.24.
993
994
995                     Added support for the double dash argument --. Use --  to
996                     stop interpreting options/environment variables and treat
997                     the next argument as the command, even if it start with -
998                     or contains a =.
999
1000       environment
1001              Display the current environment variables.
1002
1003       false  New in version 3.16.
1004
1005
1006              Do nothing, with an exit code of 1.
1007
1008       make_directory <dir>...
1009              Create  <dir> directories.  If necessary, create parent directo‐
1010              ries too.  If a directory already exists it will be silently ig‐
1011              nored.
1012
1013              New in version 3.5: Support for multiple input directories.
1014
1015
1016       md5sum <file>...
1017              Create MD5 checksum of files in md5sum compatible format:
1018
1019                 351abe79cd3800b38cdfb25d45015a15  file1.txt
1020                 052f86c15bbde68af55c7f7b340ab639  file2.txt
1021
1022       sha1sum <file>...
1023              New in version 3.10.
1024
1025
1026              Create SHA1 checksum of files in sha1sum compatible format:
1027
1028                 4bb7932a29e6f73c97bb9272f2bdc393122f86e0  file1.txt
1029                 1df4c8f318665f9a5f2ed38f55adadb7ef9f559c  file2.txt
1030
1031       sha224sum <file>...
1032              New in version 3.10.
1033
1034
1035              Create SHA224 checksum of files in sha224sum compatible format:
1036
1037                 b9b9346bc8437bbda630b0b7ddfc5ea9ca157546dbbf4c613192f930  file1.txt
1038                 6dfbe55f4d2edc5fe5c9197bca51ceaaf824e48eba0cc453088aee24  file2.txt
1039
1040       sha256sum <file>...
1041              New in version 3.10.
1042
1043
1044              Create SHA256 checksum of files in sha256sum compatible format:
1045
1046                 76713b23615d31680afeb0e9efe94d47d3d4229191198bb46d7485f9cb191acc  file1.txt
1047                 15b682ead6c12dedb1baf91231e1e89cfc7974b3787c1e2e01b986bffadae0ea  file2.txt
1048
1049       sha384sum <file>...
1050              New in version 3.10.
1051
1052
1053              Create SHA384 checksum of files in sha384sum compatible format:
1054
1055                 acc049fedc091a22f5f2ce39a43b9057fd93c910e9afd76a6411a28a8f2b8a12c73d7129e292f94fc0329c309df49434  file1.txt
1056                 668ddeb108710d271ee21c0f3acbd6a7517e2b78f9181c6a2ff3b8943af92b0195dcb7cce48aa3e17893173c0a39e23d  file2.txt
1057
1058       sha512sum <file>...
1059              New in version 3.10.
1060
1061
1062              Create SHA512 checksum of files in sha512sum compatible format:
1063
1064                 2a78d7a6c5328cfb1467c63beac8ff21794213901eaadafd48e7800289afbc08e5fb3e86aa31116c945ee3d7bf2a6194489ec6101051083d1108defc8e1dba89  file1.txt
1065                 7a0b54896fe5e70cca6dd643ad6f672614b189bf26f8153061c4d219474b05dad08c4e729af9f4b009f1a1a280cb625454bf587c690f4617c27e3aebdf3b7a2d  file2.txt
1066
1067       remove [-f] <file>...
1068              Deprecated since version 3.17.
1069
1070
1071              Remove  the file(s). The planned behavior was that if any of the
1072              listed files  already  do  not  exist,  the  command  returns  a
1073              non-zero  exit  code,  but  no  message is logged. The -f option
1074              changes the behavior to return a zero exit code  (i.e.  success)
1075              in  such  situations  instead.  remove does not follow symlinks.
1076              That means it remove only symlinks and not files it point to.
1077
1078              The implementation was buggy and always returned 0. It cannot be
1079              fixed without breaking backwards compatibility. Use rm instead.
1080
1081       remove_directory <dir>...
1082              Deprecated since version 3.17.
1083
1084
1085              Remove <dir> directories and their contents. If a directory does
1086              not exist it will be silently ignored.  Use rm instead.
1087
1088              New in version 3.15: Support for multiple directories.
1089
1090
1091              New in version 3.16: If <dir> is a symlink to a directory,  just
1092              the symlink will be removed.
1093
1094
1095       rename <oldname> <newname>
1096              Rename  a  file  or  directory (on one volume). If file with the
1097              <newname> name already exists, then  it  will  be  silently  re‐
1098              placed.
1099
1100       rm [-rRf] [--] <file|dir>...
1101              New in version 3.17.
1102
1103
1104              Remove  the  files <file> or directories <dir>.  Use -r or -R to
1105              remove directories and their contents recursively.   If  any  of
1106              the listed files/directories do not exist, the command returns a
1107              non-zero exit code, but no message  is  logged.  The  -f  option
1108              changes  the  behavior to return a zero exit code (i.e. success)
1109              in such situations instead. Use -- to stop interpreting  options
1110              and  treat  all remaining arguments as paths, even if they start
1111              with -.
1112
1113       server Launch cmake-server(7) mode.
1114
1115       sleep <number>...
1116              New in version 3.0.
1117
1118
1119              Sleep for given number of seconds.
1120
1121       tar [cxt][vf][zjJ] file.tar [<options>] [--] [<pathname>...]
1122              Create or extract a tar or zip archive.  Options are:
1123
1124              c      Create a new archive containing the specified files.   If
1125                     used, the <pathname>... argument is mandatory.
1126
1127              x      Extract to disk from the archive.
1128
1129                     New  in version 3.15: The <pathname>... argument could be
1130                     used to extract only selected files or directories.  When
1131                     extracting  selected  files or directories, you must pro‐
1132                     vide their exact names including the path, as printed  by
1133                     list (-t).
1134
1135
1136              t      List archive contents.
1137
1138                     New  in version 3.15: The <pathname>... argument could be
1139                     used to list only selected files or directories.
1140
1141
1142              v      Produce verbose output.
1143
1144              z      Compress the resulting archive with gzip.
1145
1146              j      Compress the resulting archive with bzip2.
1147
1148              J      New in version 3.1.
1149
1150
1151                     Compress the resulting archive with XZ.
1152
1153              --zstd New in version 3.15.
1154
1155
1156                     Compress the resulting archive with Zstandard.
1157
1158              --files-from=<file>
1159                     New in version 3.1.
1160
1161
1162                     Read file names from the given file, one per line.  Blank
1163                     lines  are  ignored.  Lines may not start in - except for
1164                     --add-file=<name> to add files whose names start in -.
1165
1166              --format=<format>
1167                     New in version 3.3.
1168
1169
1170                     Specify the format of the archive to  be  created.   Sup‐
1171                     ported  formats  are: 7zip, gnutar, pax, paxr (restricted
1172                     pax, default), and zip.
1173
1174              --mtime=<date>
1175                     New in version 3.1.
1176
1177
1178                     Specify modification time recorded in tarball entries.
1179
1180              --touch
1181                     New in version 3.24.
1182
1183
1184                     Use current local timestamp instead  of  extracting  file
1185                     timestamps from the archive.
1186
1187              --     New in version 3.1.
1188
1189
1190                     Stop  interpreting  options and treat all remaining argu‐
1191                     ments as file names, even if they start with -.
1192
1193              New in version 3.1: LZMA (7zip) support.
1194
1195
1196              New in version 3.15: The command now continues adding  files  to
1197              an archive even if some of the files are not readable.  This be‐
1198              havior is more consistent with the classic tar tool. The command
1199              now  also parses all flags, and if an invalid flag was provided,
1200              a warning is issued.
1201
1202
1203       time <command> [<args>...]
1204              Run command and display elapsed time.
1205
1206              New in version 3.5: The command now  properly  passes  arguments
1207              with  spaces or special characters through to the child process.
1208              This may break scripts that worked around the bug with their own
1209              extra quoting or escaping.
1210
1211
1212       touch <file>...
1213              Creates  <file>  if  file do not exist.  If <file> exists, it is
1214              changing <file> access and modification times.
1215
1216       touch_nocreate <file>...
1217              Touch a file if it exists but do not create it.  If a file  does
1218              not exist it will be silently ignored.
1219
1220       true   New in version 3.16.
1221
1222
1223              Do nothing, with an exit code of 0.
1224
1225   Windows-specific Command-Line Tools
1226       The following cmake -E commands are available only on Windows:
1227
1228       delete_regv <key>
1229              Delete Windows registry value.
1230
1231       env_vs8_wince <sdkname>
1232              New in version 3.2.
1233
1234
1235              Displays  a  batch  file which sets the environment for the pro‐
1236              vided Windows CE SDK installed in VS2005.
1237
1238       env_vs9_wince <sdkname>
1239              New in version 3.2.
1240
1241
1242              Displays a batch file which sets the environment  for  the  pro‐
1243              vided Windows CE SDK installed in VS2008.
1244
1245       write_regv <key> <value>
1246              Write Windows registry value.
1247

RUN THE FIND-PACKAGE TOOL

1249       CMake provides a pkg-config like helper for Makefile-based projects:
1250
1251          cmake --find-package [<options>]
1252
1253       It  searches  a  package  using find_package() and prints the resulting
1254       flags to stdout.  This can be used instead of pkg-config  to  find  in‐
1255       stalled libraries in plain Makefile-based projects or in autoconf-based
1256       projects (via share/aclocal/cmake.m4).
1257
1258       NOTE:
1259          This mode is not well-supported due to some  technical  limitations.
1260          It is kept for compatibility but should not be used in new projects.
1261

RUN A WORKFLOW PRESET

1263       CMake Presets provides a way to execute multiple build steps in order:
1264
1265          cmake --workflow [<options>]
1266
1267       The options are:
1268
1269       --workflow
1270              Select a Workflow Preset using one of the following options.
1271
1272       --preset <preset>, --preset=<preset>
1273              Use  a workflow preset to specify a workflow. The project binary
1274              directory is inferred from the  initial  configure  preset.  The
1275              current  working directory must contain CMake preset files.  See
1276              preset for more details.
1277
1278       --list-presets
1279              Lists the available workflow presets. The current working direc‐
1280              tory must contain CMake preset files.
1281
1282       --fresh
1283              Perform  a  fresh configuration of the build tree.  This removes
1284              any existing CMakeCache.txt file and associated CMakeFiles/  di‐
1285              rectory, and recreates them from scratch.
1286

VIEW HELP

1288       To print selected pages from the CMake documentation, use
1289
1290          cmake --help[-<topic>]
1291
1292       with one of the following options:
1293
1294       -version [<file>], --version [<file>], /V [<file>]
1295              Show  program  name/version  banner  and  exit.   The  output is
1296              printed to a named <file> if given.
1297
1298       -h, -H, --help, -help, -usage, /?
1299              Print usage information and exit.
1300
1301              Usage describes the basic command line  interface  and  its  op‐
1302              tions.
1303
1304       --help-full [<file>]
1305              Print all help manuals and exit.
1306
1307              All  manuals  are  printed in a human-readable text format.  The
1308              output is printed to a named <file> if given.
1309
1310       --help-manual <man> [<file>]
1311              Print one help manual and exit.
1312
1313              The specified manual is printed in a human-readable text format.
1314              The output is printed to a named <file> if given.
1315
1316       --help-manual-list [<file>]
1317              List help manuals available and exit.
1318
1319              The  list contains all manuals for which help may be obtained by
1320              using the --help-manual option followed by a manual  name.   The
1321              output is printed to a named <file> if given.
1322
1323       --help-command <cmd> [<file>]
1324              Print help for one command and exit.
1325
1326              The cmake-commands(7) manual entry for <cmd> is printed in a hu‐
1327              man-readable text format.  The output  is  printed  to  a  named
1328              <file> if given.
1329
1330       --help-command-list [<file>]
1331              List commands with help available and exit.
1332
1333              The list contains all commands for which help may be obtained by
1334              using the --help-command option followed by a command name.  The
1335              output is printed to a named <file> if given.
1336
1337       --help-commands [<file>]
1338              Print cmake-commands manual and exit.
1339
1340              The cmake-commands(7) manual is printed in a human-readable text
1341              format.  The output is printed to a named <file> if given.
1342
1343       --help-module <mod> [<file>]
1344              Print help for one module and exit.
1345
1346              The cmake-modules(7) manual entry for <mod> is printed in a  hu‐
1347              man-readable  text  format.   The  output  is printed to a named
1348              <file> if given.
1349
1350       --help-module-list [<file>]
1351              List modules with help available and exit.
1352
1353              The list contains all modules for which help may be obtained  by
1354              using  the  --help-module option followed by a module name.  The
1355              output is printed to a named <file> if given.
1356
1357       --help-modules [<file>]
1358              Print cmake-modules manual and exit.
1359
1360              The cmake-modules(7) manual is printed in a human-readable  text
1361              format.  The output is printed to a named <file> if given.
1362
1363       --help-policy <cmp> [<file>]
1364              Print help for one policy and exit.
1365
1366              The cmake-policies(7) manual entry for <cmp> is printed in a hu‐
1367              man-readable text format.  The output  is  printed  to  a  named
1368              <file> if given.
1369
1370       --help-policy-list [<file>]
1371              List policies with help available and exit.
1372
1373              The list contains all policies for which help may be obtained by
1374              using the --help-policy option followed by a policy  name.   The
1375              output is printed to a named <file> if given.
1376
1377       --help-policies [<file>]
1378              Print cmake-policies manual and exit.
1379
1380              The cmake-policies(7) manual is printed in a human-readable text
1381              format.  The output is printed to a named <file> if given.
1382
1383       --help-property <prop> [<file>]
1384              Print help for one property and exit.
1385
1386              The cmake-properties(7) manual entries for <prop> are printed in
1387              a  human-readable text format.  The output is printed to a named
1388              <file> if given.
1389
1390       --help-property-list [<file>]
1391              List properties with help available and exit.
1392
1393              The list contains all properties for which help may be  obtained
1394              by using the --help-property option followed by a property name.
1395              The output is printed to a named <file> if given.
1396
1397       --help-properties [<file>]
1398              Print cmake-properties manual and exit.
1399
1400              The cmake-properties(7) manual is printed  in  a  human-readable
1401              text format.  The output is printed to a named <file> if given.
1402
1403       --help-variable <var> [<file>]
1404              Print help for one variable and exit.
1405
1406              The  cmake-variables(7)  manual  entry for <var> is printed in a
1407              human-readable text format.  The output is printed  to  a  named
1408              <file> if given.
1409
1410       --help-variable-list [<file>]
1411              List variables with help available and exit.
1412
1413              The  list  contains all variables for which help may be obtained
1414              by using the --help-variable option followed by a variable name.
1415              The output is printed to a named <file> if given.
1416
1417       --help-variables [<file>]
1418              Print cmake-variables manual and exit.
1419
1420              The  cmake-variables(7)  manual  is  printed in a human-readable
1421              text format.  The output is printed to a named <file> if given.
1422
1423       To view the presets available for a project, use
1424
1425          cmake <source-dir> --list-presets
1426

RETURN VALUE (EXIT CODE)

1428       Upon regular termination, the cmake executable returns the exit code 0.
1429
1430       If termination is caused by the command  message(FATAL_ERROR),  or  an‐
1431       other error condition, then a non-zero exit code is returned.
1432

SEE ALSO

1434       The following resources are available to get help using CMake:
1435
1436       Home Page
1437              https://cmake.org
1438
1439              The primary starting point for learning about CMake.
1440
1441       Online Documentation and Community Resources
1442              https://cmake.org/documentation
1443
1444              Links  to available documentation and community resources may be
1445              found on this web page.
1446
1447       Discourse Forum
1448              https://discourse.cmake.org
1449
1450              The Discourse Forum hosts discussion and questions about CMake.
1451
1453       2000-2023 Kitware, Inc. and Contributors
1454
1455
1456
1457
14583.25.2                           Jan 19, 2023                         CMAKE(1)
Impressum