cmake.1.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. .. cmake-manual-description: CMake Command-Line Reference
  2. cmake(1)
  3. ********
  4. Synopsis
  5. ========
  6. .. parsed-literal::
  7. cmake [<options>] (<path-to-source> | <path-to-existing-build>)
  8. cmake [(-D <var>=<value>)...] -P <cmake-script-file>
  9. cmake --build <dir> [<options>...] [-- <build-tool-options>...]
  10. cmake -E <command> [<options>...]
  11. cmake --find-package <options>...
  12. Description
  13. ===========
  14. The "cmake" executable is the CMake command-line interface. It may be
  15. used to configure projects in scripts. Project configuration settings
  16. may be specified on the command line with the -D option.
  17. CMake is a cross-platform build system generator. Projects specify
  18. their build process with platform-independent CMake listfiles included
  19. in each directory of a source tree with the name CMakeLists.txt.
  20. Users build a project by using CMake to generate a build system for a
  21. native tool on their platform.
  22. .. _`CMake Options`:
  23. Options
  24. =======
  25. .. include:: OPTIONS_BUILD.txt
  26. ``-E <command> [<options>...]``
  27. See `Command-Line Tool Mode`_.
  28. ``-L[A][H]``
  29. List non-advanced cached variables.
  30. List cache variables will run CMake and list all the variables from
  31. the CMake cache that are not marked as INTERNAL or ADVANCED. This
  32. will effectively display current CMake settings, which can then be
  33. changed with -D option. Changing some of the variables may result
  34. in more variables being created. If A is specified, then it will
  35. display also advanced variables. If H is specified, it will also
  36. display help for each variable.
  37. ``--build <dir>``
  38. See `Build Tool Mode`_.
  39. ``-N``
  40. View mode only.
  41. Only load the cache. Do not actually run configure and generate
  42. steps.
  43. ``-P <file>``
  44. Process script mode.
  45. Process the given cmake file as a script written in the CMake
  46. language. No configure or generate step is performed and the cache
  47. is not modified. If variables are defined using -D, this must be
  48. done before the -P argument.
  49. ``--find-package``
  50. See `Find-Package Tool Mode`_.
  51. ``--graphviz=[file]``
  52. Generate graphviz of dependencies, see CMakeGraphVizOptions.cmake for more.
  53. Generate a graphviz input file that will contain all the library and
  54. executable dependencies in the project. See the documentation for
  55. CMakeGraphVizOptions.cmake for more details.
  56. ``--system-information [file]``
  57. Dump information about this system.
  58. Dump a wide range of information about the current system. If run
  59. from the top of a binary tree for a CMake project it will dump
  60. additional information such as the cache, log files etc.
  61. ``--debug-trycompile``
  62. Do not delete the try_compile build tree. Only useful on one try_compile at a time.
  63. Do not delete the files and directories created for try_compile
  64. calls. This is useful in debugging failed try_compiles. It may
  65. however change the results of the try-compiles as old junk from a
  66. previous try-compile may cause a different test to either pass or
  67. fail incorrectly. This option is best used for one try-compile at a
  68. time, and only when debugging.
  69. ``--debug-output``
  70. Put cmake in a debug mode.
  71. Print extra information during the cmake run like stack traces with
  72. message(send_error ) calls.
  73. ``--trace``
  74. Put cmake in trace mode.
  75. Print a trace of all calls made and from where.
  76. ``--trace-expand``
  77. Put cmake in trace mode.
  78. Like ``--trace``, but with variables expanded.
  79. ``--trace-source=<file>``
  80. Put cmake in trace mode, but output only lines of a specified file.
  81. Multiple options are allowed.
  82. ``--warn-uninitialized``
  83. Warn about uninitialized values.
  84. Print a warning when an uninitialized variable is used.
  85. ``--warn-unused-vars``
  86. Warn about unused variables.
  87. Find variables that are declared or set, but not used.
  88. ``--no-warn-unused-cli``
  89. Don't warn about command line options.
  90. Don't find variables that are declared on the command line, but not
  91. used.
  92. ``--check-system-vars``
  93. Find problems with variable usage in system files.
  94. Normally, unused and uninitialized variables are searched for only
  95. in CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. This flag tells CMake to
  96. warn about other files as well.
  97. .. include:: OPTIONS_HELP.txt
  98. Build Tool Mode
  99. ===============
  100. CMake provides a command-line signature to build an already-generated
  101. project binary tree::
  102. cmake --build <dir> [<options>...] [-- <build-tool-options>...]
  103. This abstracts a native build tool's command-line interface with the
  104. following options:
  105. ``--build <dir>``
  106. Project binary directory to be built. This is required and must be first.
  107. ``--target <tgt>``
  108. Build ``<tgt>`` instead of default targets. May only be specified once.
  109. ``--config <cfg>``
  110. For multi-configuration tools, choose configuration ``<cfg>``.
  111. ``--clean-first``
  112. Build target ``clean`` first, then build.
  113. (To clean only, use ``--target clean``.)
  114. ``--use-stderr``
  115. Ignored. Behavior is default in CMake >= 3.0.
  116. ``--``
  117. Pass remaining options to the native tool.
  118. Run ``cmake --build`` with no options for quick help.
  119. Command-Line Tool Mode
  120. ======================
  121. CMake provides builtin command-line tools through the signature::
  122. cmake -E <command> [<options>...]
  123. Run ``cmake -E`` or ``cmake -E help`` for a summary of commands.
  124. Available commands are:
  125. ``capabilities``
  126. Report cmake capabilities in JSON format. The output is a JSON object
  127. with the following keys:
  128. ``version``
  129. A JSON object with version information. Keys are:
  130. ``string``
  131. The full version string as displayed by cmake ``--version``.
  132. ``major``
  133. The major version number in integer form.
  134. ``minor``
  135. The minor version number in integer form.
  136. ``patch``
  137. The patch level in integer form.
  138. ``suffix``
  139. The cmake version suffix string.
  140. ``isDirty``
  141. A bool that is set if the cmake build is from a dirty tree.
  142. ``generators``
  143. A list available generators. Each generator is a JSON object with the
  144. following keys:
  145. ``name``
  146. A string containing the name of the generator.
  147. ``toolsetSupport``
  148. ``true`` if the generator supports toolsets and ``false`` otherwise.
  149. ``platformSupport``
  150. ``true`` if the generator supports platforms and ``false`` otherwise.
  151. ``extraGenerators``
  152. A list of strings with all the extra generators compatible with
  153. the generator.
  154. ``serverMode``
  155. ``true`` if cmake supports server-mode and ``false`` otherwise.
  156. ``chdir <dir> <cmd> [<arg>...]``
  157. Change the current working directory and run a command.
  158. ``compare_files <file1> <file2>``
  159. Check if ``<file1>`` is same as ``<file2>``. If files are the same,
  160. then returns 0, if not it returns 1.
  161. ``copy <file>... <destination>``
  162. Copy files to ``<destination>`` (either file or directory).
  163. If multiple files are specified, the ``<destination>`` must be
  164. directory and it must exist.
  165. ``copy_directory <dir>... <destination>``
  166. Copy directories to ``<destination>`` directory.
  167. If ``<destination>`` directory does not exist it will be created.
  168. ``copy_if_different <file>... <destination>``
  169. Copy files to ``<destination>`` (either file or directory) if
  170. they have changed.
  171. If multiple files are specified, the ``<destination>`` must be
  172. directory and it must exist.
  173. ``echo [<string>...]``
  174. Displays arguments as text.
  175. ``echo_append [<string>...]``
  176. Displays arguments as text but no new line.
  177. ``env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...``
  178. Run command in a modified environment.
  179. ``environment``
  180. Display the current environment variables.
  181. ``make_directory <dir>...``
  182. Create ``<dir>`` directories. If necessary, create parent
  183. directories too. If a directory already exists it will be
  184. silently ignored.
  185. ``md5sum <file>...``
  186. Create MD5 checksum of files in ``md5sum`` compatible format::
  187. 351abe79cd3800b38cdfb25d45015a15 file1.txt
  188. 052f86c15bbde68af55c7f7b340ab639 file2.txt
  189. ``remove [-f] <file>...``
  190. Remove the file(s), use ``-f`` to force it. If a file does
  191. not exist it will be silently ignored.
  192. ``remove_directory <dir>``
  193. Remove a directory and its contents. If a directory does
  194. not exist it will be silently ignored.
  195. ``rename <oldname> <newname>``
  196. Rename a file or directory (on one volume).
  197. ``server``
  198. Launch :manual:`cmake-server(7)` mode.
  199. ``sleep <number>...``
  200. Sleep for given number of seconds.
  201. ``tar [cxt][vf][zjJ] file.tar [<options>...] [--] [<file>...]``
  202. Create or extract a tar or zip archive. Options are:
  203. ``--``
  204. Stop interpreting options and treat all remaining arguments
  205. as file names even if they start in ``-``.
  206. ``--files-from=<file>``
  207. Read file names from the given file, one per line.
  208. Blank lines are ignored. Lines may not start in ``-``
  209. except for ``--add-file=<name>`` to add files whose
  210. names start in ``-``.
  211. ``--mtime=<date>``
  212. Specify modification time recorded in tarball entries.
  213. ``--format=<format>``
  214. Specify the format of the archive to be created.
  215. Supported formats are: ``7zip``, ``gnutar``, ``pax``,
  216. ``paxr`` (restricted pax, default), and ``zip``.
  217. ``time <command> [<args>...]``
  218. Run command and return elapsed time.
  219. ``touch <file>``
  220. Touch a file.
  221. ``touch_nocreate <file>``
  222. Touch a file if it exists but do not create it. If a file does
  223. not exist it will be silently ignored.
  224. UNIX-specific Command-Line Tools
  225. --------------------------------
  226. The following ``cmake -E`` commands are available only on UNIX:
  227. ``create_symlink <old> <new>``
  228. Create a symbolic link ``<new>`` naming ``<old>``.
  229. Windows-specific Command-Line Tools
  230. -----------------------------------
  231. The following ``cmake -E`` commands are available only on Windows:
  232. ``delete_regv <key>``
  233. Delete Windows registry value.
  234. ``env_vs8_wince <sdkname>``
  235. Displays a batch file which sets the environment for the provided
  236. Windows CE SDK installed in VS2005.
  237. ``env_vs9_wince <sdkname>``
  238. Displays a batch file which sets the environment for the provided
  239. Windows CE SDK installed in VS2008.
  240. ``write_regv <key> <value>``
  241. Write Windows registry value.
  242. Find-Package Tool Mode
  243. ======================
  244. CMake provides a helper for Makefile-based projects with the signature::
  245. cmake --find-package <options>...
  246. This runs in a pkg-config like mode.
  247. Search a package using :command:`find_package()` and print the resulting flags
  248. to stdout. This can be used to use cmake instead of pkg-config to find
  249. installed libraries in plain Makefile-based projects or in autoconf-based
  250. projects (via ``share/aclocal/cmake.m4``).
  251. .. note::
  252. This mode is not well-supported due to some technical limitations.
  253. It is kept for compatibility but should not be used in new projects.
  254. See Also
  255. ========
  256. .. include:: LINKS.txt