cmake.1.rst 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. ``--warn-uninitialized``
  80. Warn about uninitialized values.
  81. Print a warning when an uninitialized variable is used.
  82. ``--warn-unused-vars``
  83. Warn about unused variables.
  84. Find variables that are declared or set, but not used.
  85. ``--no-warn-unused-cli``
  86. Don't warn about command line options.
  87. Don't find variables that are declared on the command line, but not
  88. used.
  89. ``--check-system-vars``
  90. Find problems with variable usage in system files.
  91. Normally, unused and uninitialized variables are searched for only
  92. in CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. This flag tells CMake to
  93. warn about other files as well.
  94. .. include:: OPTIONS_HELP.txt
  95. Build Tool Mode
  96. ===============
  97. CMake provides a command-line signature to build an already-generated
  98. project binary tree::
  99. cmake --build <dir> [<options>...] [-- <build-tool-options>...]
  100. This abstracts a native build tool's command-line interface with the
  101. following options:
  102. ``--build <dir>``
  103. Project binary directory to be built. This is required and must be first.
  104. ``--target <tgt>``
  105. Build ``<tgt>`` instead of default targets. May only be specified once.
  106. ``--config <cfg>``
  107. For multi-configuration tools, choose configuration ``<cfg>``.
  108. ``--clean-first``
  109. Build target ``clean`` first, then build.
  110. (To clean only, use ``--target clean``.)
  111. ``--use-stderr``
  112. Ignored. Behavior is default in CMake >= 3.0.
  113. ``--``
  114. Pass remaining options to the native tool.
  115. Run ``cmake --build`` with no options for quick help.
  116. Command-Line Tool Mode
  117. ======================
  118. CMake provides builtin command-line tools through the signature::
  119. cmake -E <command> [<options>...]
  120. Run ``cmake -E`` or ``cmake -E help`` for a summary of commands.
  121. Available commands are:
  122. ``chdir <dir> <cmd> [<arg>...]``
  123. Change the current working directory and run a command.
  124. ``compare_files <file1> <file2>``
  125. Check if ``<file1>`` is same as ``<file2>``. If files are the same,
  126. then returns 0, if not it returns 1.
  127. ``copy <file>... <destination>``
  128. Copy files to ``<destination>`` (either file or directory).
  129. If multiple files are specified, the ``<destination>`` must be
  130. directory and it must exist.
  131. ``copy_directory <dir>... <destination>``
  132. Copy directories to ``<destination>`` directory.
  133. If ``<destination>`` directory does not exist it will be created.
  134. ``copy_if_different <file>... <destination>``
  135. Copy files to ``<destination>`` (either file or directory) if
  136. they have changed.
  137. If multiple files are specified, the ``<destination>`` must be
  138. directory and it must exist.
  139. ``echo [<string>...]``
  140. Displays arguments as text.
  141. ``echo_append [<string>...]``
  142. Displays arguments as text but no new line.
  143. ``env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...``
  144. Run command in a modified environment.
  145. ``environment``
  146. Display the current environment variables.
  147. ``make_directory <dir>...``
  148. Create ``<dir>`` directories. If necessary, create parent
  149. directories too. If a directory already exists it will be
  150. silently ignored.
  151. ``md5sum <file>...``
  152. Create MD5 checksum of files in ``md5sum`` compatible format::
  153. 351abe79cd3800b38cdfb25d45015a15 file1.txt
  154. 052f86c15bbde68af55c7f7b340ab639 file2.txt
  155. ``remove [-f] <file>...``
  156. Remove the file(s), use ``-f`` to force it. If a file does
  157. not exist it will be silently ignored.
  158. ``remove_directory <dir>``
  159. Remove a directory and its contents. If a directory does
  160. not exist it will be silently ignored.
  161. ``rename <oldname> <newname>``
  162. Rename a file or directory (on one volume).
  163. ``sleep <number>...``
  164. Sleep for given number of seconds.
  165. ``tar [cxt][vf][zjJ] file.tar [<options>...] [--] [<file>...]``
  166. Create or extract a tar or zip archive. Options are:
  167. ``--``
  168. Stop interpreting options and treat all remaining arguments
  169. as file names even if they start in ``-``.
  170. ``--files-from=<file>``
  171. Read file names from the given file, one per line.
  172. Blank lines are ignored. Lines may not start in ``-``
  173. except for ``--add-file=<name>`` to add files whose
  174. names start in ``-``.
  175. ``--mtime=<date>``
  176. Specify modification time recorded in tarball entries.
  177. ``--format=<format>``
  178. Specify the format of the archive to be created.
  179. Supported formats are: ``7zip``, ``gnutar``, ``pax``,
  180. ``paxr`` (restricted pax, default), and ``zip``.
  181. ``time <command> [<args>...]``
  182. Run command and return elapsed time.
  183. ``touch <file>``
  184. Touch a file.
  185. ``touch_nocreate <file>``
  186. Touch a file if it exists but do not create it. If a file does
  187. not exist it will be silently ignored.
  188. UNIX-specific Command-Line Tools
  189. --------------------------------
  190. The following ``cmake -E`` commands are available only on UNIX:
  191. ``create_symlink <old> <new>``
  192. Create a symbolic link ``<new>`` naming ``<old>``.
  193. Windows-specific Command-Line Tools
  194. -----------------------------------
  195. The following ``cmake -E`` commands are available only on Windows:
  196. ``delete_regv <key>``
  197. Delete Windows registry value.
  198. ``env_vs8_wince <sdkname>``
  199. Displays a batch file which sets the environment for the provided
  200. Windows CE SDK installed in VS2005.
  201. ``env_vs9_wince <sdkname>``
  202. Displays a batch file which sets the environment for the provided
  203. Windows CE SDK installed in VS2008.
  204. ``write_regv <key> <value>``
  205. Write Windows registry value.
  206. Find-Package Tool Mode
  207. ======================
  208. CMake provides a helper for Makefile-based projects with the signature::
  209. cmake --find-package <options>...
  210. This runs in a pkg-config like mode.
  211. Search a package using :command:`find_package()` and print the resulting flags
  212. to stdout. This can be used to use cmake instead of pkg-config to find
  213. installed libraries in plain Makefile-based projects or in autoconf-based
  214. projects (via ``share/aclocal/cmake.m4``).
  215. .. note::
  216. This mode is not well-supported due to some technical limitations.
  217. It is kept for compatibility but should not be used in new projects.
  218. See Also
  219. ========
  220. .. include:: LINKS.txt