cmake.1.rst 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. Build a CMake-generated project binary tree.
  39. This abstracts a native build tool's command-line interface with the
  40. following options:
  41. ::
  42. <dir> = Project binary directory to be built.
  43. --target <tgt> = Build <tgt> instead of default targets.
  44. --config <cfg> = For multi-configuration tools, choose <cfg>.
  45. --clean-first = Build target 'clean' first, then build.
  46. (To clean only, use --target 'clean'.)
  47. --use-stderr = Ignored. Behavior is default in CMake >= 3.0.
  48. -- = Pass remaining options to the native tool.
  49. Run cmake --build with no options for quick help.
  50. ``-N``
  51. View mode only.
  52. Only load the cache. Do not actually run configure and generate
  53. steps.
  54. ``-P <file>``
  55. Process script mode.
  56. Process the given cmake file as a script written in the CMake
  57. language. No configure or generate step is performed and the cache
  58. is not modified. If variables are defined using -D, this must be
  59. done before the -P argument.
  60. ``--find-package``
  61. Run in pkg-config like mode.
  62. Search a package using find_package() and print the resulting flags
  63. to stdout. This can be used to use cmake instead of pkg-config to
  64. find installed libraries in plain Makefile-based projects or in
  65. autoconf-based projects (via share/aclocal/cmake.m4).
  66. ``--graphviz=[file]``
  67. Generate graphviz of dependencies, see CMakeGraphVizOptions.cmake for more.
  68. Generate a graphviz input file that will contain all the library and
  69. executable dependencies in the project. See the documentation for
  70. CMakeGraphVizOptions.cmake for more details.
  71. ``--system-information [file]``
  72. Dump information about this system.
  73. Dump a wide range of information about the current system. If run
  74. from the top of a binary tree for a CMake project it will dump
  75. additional information such as the cache, log files etc.
  76. ``--debug-trycompile``
  77. Do not delete the try_compile build tree. Only useful on one try_compile at a time.
  78. Do not delete the files and directories created for try_compile
  79. calls. This is useful in debugging failed try_compiles. It may
  80. however change the results of the try-compiles as old junk from a
  81. previous try-compile may cause a different test to either pass or
  82. fail incorrectly. This option is best used for one try-compile at a
  83. time, and only when debugging.
  84. ``--debug-output``
  85. Put cmake in a debug mode.
  86. Print extra information during the cmake run like stack traces with
  87. message(send_error ) calls.
  88. ``--trace``
  89. Put cmake in trace mode.
  90. Print a trace of all calls made and from where.
  91. ``--trace-expand``
  92. Put cmake in trace mode.
  93. Like ``--trace``, but with variables expanded.
  94. ``--warn-uninitialized``
  95. Warn about uninitialized values.
  96. Print a warning when an uninitialized variable is used.
  97. ``--warn-unused-vars``
  98. Warn about unused variables.
  99. Find variables that are declared or set, but not used.
  100. ``--no-warn-unused-cli``
  101. Don't warn about command line options.
  102. Don't find variables that are declared on the command line, but not
  103. used.
  104. ``--check-system-vars``
  105. Find problems with variable usage in system files.
  106. Normally, unused and uninitialized variables are searched for only
  107. in CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. This flag tells CMake to
  108. warn about other files as well.
  109. .. include:: OPTIONS_HELP.txt
  110. Command-Line Tool Mode
  111. ======================
  112. CMake provides builtin command-line tools through the signature::
  113. cmake -E <command> [<options>...]
  114. Run ``cmake -E`` or ``cmake -E help`` for a summary of commands.
  115. Available commands are:
  116. ``chdir <dir> <cmd> [<arg>...]``
  117. Change the current working directory and run a command.
  118. ``compare_files <file1> <file2>``
  119. Check if ``<file1>`` is same as ``<file2>``. If files are the same,
  120. then returns 0, if not itreturns 1.
  121. ``copy <file>... <destination>``
  122. Copy files to ``<destination>`` (either file or directory).
  123. If multiple files are specified, the ``<destination>`` must be
  124. directory and it must exist.
  125. ``copy_directory <dir>... <destination>``
  126. Copy directories to ``<destination>`` directory.
  127. If ``<destination>`` directory does not exist it will be created.
  128. ``copy_if_different <file>... <destination>``
  129. Copy files to ``<destination>`` (either file or directory) if
  130. they have changed.
  131. If multiple files are specified, the ``<destination>`` must be
  132. directory and it must exist.
  133. ``echo [<string>...]``
  134. Displays arguments as text.
  135. ``echo_append [<string>...]``
  136. Displays arguments as text but no new line.
  137. ``env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...``
  138. Run command in a modified environment.
  139. ``environment``
  140. Display the current environment variables.
  141. ``make_directory <dir>...``
  142. Create ``<dir>`` directories. If necessary, create parent
  143. directories too.
  144. ``md5sum <file>...``
  145. Compute md5sum of files.
  146. ``remove [-f] <file>...``
  147. Remove the file(s), use ``-f`` to force it.
  148. ``remove_directory <dir>``
  149. Remove a directory and its contents.
  150. ``rename <oldname> <newname>``
  151. Rename a file or directory (on one volume).
  152. ``sleep <number>...``
  153. Sleep for given number of seconds.
  154. ``tar [cxt][vf][zjJ] file.tar [<options>...] [--] [<file>...]``
  155. Create or extract a tar or zip archive. Options are:
  156. ``--``
  157. Stop interpreting options and treat all remaining arguments
  158. as file names even if they start in ``-``.
  159. ``--files-from=<file>``
  160. Read file names from the given file, one per line.
  161. Blank lines are ignored. Lines may not start in ``-``
  162. except for ``--add-file=<name>`` to add files whose
  163. names start in ``-``.
  164. ``--mtime=<date>``
  165. Specify modification time recorded in tarball entries.
  166. ``--format=<format>``
  167. Specify the format of the archive to be created.
  168. Supported formats are: ``7zip``, ``gnutar``, ``pax``,
  169. ``paxr`` (restricted pax, default), and ``zip``.
  170. ``time <command> [<args>...]``
  171. Run command and return elapsed time.
  172. ``touch <file>``
  173. Touch a file.
  174. ``touch_nocreate <file>``
  175. Touch a file if it exists but do not create it.
  176. UNIX-specific Command-Line Tools
  177. --------------------------------
  178. The following ``cmake -E`` commands are available only on UNIX:
  179. ``create_symlink <old> <new>``
  180. Create a symbolic link ``<new>`` naming ``<old>``.
  181. Windows-specific Command-Line Tools
  182. -----------------------------------
  183. The following ``cmake -E`` commands are available only on Windows:
  184. ``delete_regv <key>``
  185. Delete Windows registry value.
  186. ``env_vs8_wince <sdkname>``
  187. Displays a batch file which sets the environment for the provided
  188. Windows CE SDK installed in VS2005.
  189. ``env_vs9_wince <sdkname>``
  190. Displays a batch file which sets the environment for the provided
  191. Windows CE SDK installed in VS2008.
  192. ``write_regv <key> <value>``
  193. Write Windows registry value.
  194. See Also
  195. ========
  196. .. include:: LINKS.txt