You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1008 lines
32 KiB

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