Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Help / manual / OPTIONS_BUILD.txt
1 .. option:: -S <path-to-source>
2
3  Path to root directory of the CMake project to build.
4
5 .. option:: -B <path-to-build>
6
7  Path to directory which CMake will use as the root of build directory.
8
9  If the directory doesn't already exist CMake will make it.
10
11 .. option:: -C <initial-cache>
12
13  Pre-load a script to populate the cache.
14
15  When CMake is first run in an empty build tree, it creates a
16  ``CMakeCache.txt`` file and populates it with customizable settings for
17  the project.  This option may be used to specify a file from which
18  to load cache entries before the first pass through the project's
19  CMake listfiles.  The loaded entries take priority over the
20  project's default values.  The given file should be a CMake script
21  containing :command:`set` commands that use the ``CACHE`` option, not a
22  cache-format file.
23
24  References to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR`
25  within the script evaluate to the top-level source and build tree.
26
27 .. option:: -D <var>:<type>=<value>, -D <var>=<value>
28
29  Create or update a CMake ``CACHE`` entry.
30
31  When CMake is first run in an empty build tree, it creates a
32  ``CMakeCache.txt`` file and populates it with customizable settings for
33  the project.  This option may be used to specify a setting that
34  takes priority over the project's default value.  The option may be
35  repeated for as many ``CACHE`` entries as desired.
36
37  If the ``:<type>`` portion is given it must be one of the types
38  specified by the :command:`set` command documentation for its
39  ``CACHE`` signature.
40  If the ``:<type>`` portion is omitted the entry will be created
41  with no type if it does not exist with a type already.  If a
42  command in the project sets the type to ``PATH`` or ``FILEPATH``
43  then the ``<value>`` will be converted to an absolute path.
44
45  This option may also be given as a single argument:
46  ``-D<var>:<type>=<value>`` or ``-D<var>=<value>``.
47
48  It's important to note that the order of ``-C`` and ``-D`` arguments is
49  significant. They will be carried out in the order they are listed, with the
50  last argument taking precedence over the previous ones. For example, if you
51  specify ``-DCMAKE_BUILD_TYPE=Debug``, followed by a ``-C`` argument with a
52  file that calls:
53
54  .. code-block:: cmake
55
56    set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
57
58  then the ``-C`` argument will take precedence, and ``CMAKE_BUILD_TYPE`` will
59  be set to ``Release``. However, if the ``-D`` argument comes after the ``-C``
60  argument, it will be set to ``Debug``.
61
62  If a ``set(... CACHE ...)`` call in the ``-C`` file does not use ``FORCE``,
63  and a ``-D`` argument sets the same variable, the ``-D`` argument will take
64  precedence regardless of order because of the nature of non-``FORCE``
65  ``set(... CACHE ...)`` calls.
66
67 .. option:: -U <globbing_expr>
68
69  Remove matching entries from CMake ``CACHE``.
70
71  This option may be used to remove one or more variables from the
72  ``CMakeCache.txt`` file, globbing expressions using ``*`` and ``?`` are
73  supported.  The option may be repeated for as many ``CACHE`` entries as
74  desired.
75
76  Use with care, you can make your ``CMakeCache.txt`` non-working.
77
78 .. option:: -G <generator-name>
79
80  Specify a build system generator.
81
82  CMake may support multiple native build systems on certain
83  platforms.  A generator is responsible for generating a particular
84  build system.  Possible generator names are specified in the
85  :manual:`cmake-generators(7)` manual.
86
87  If not specified, CMake checks the :envvar:`CMAKE_GENERATOR` environment
88  variable and otherwise falls back to a builtin default selection.
89
90 .. option:: -T <toolset-spec>
91
92  Toolset specification for the generator, if supported.
93
94  Some CMake generators support a toolset specification to tell
95  the native build system how to choose a compiler.  See the
96  :variable:`CMAKE_GENERATOR_TOOLSET` variable for details.
97
98 .. option:: -A <platform-name>
99
100  Specify platform name if supported by generator.
101
102  Some CMake generators support a platform name to be given to the
103  native build system to choose a compiler or SDK.  See the
104  :variable:`CMAKE_GENERATOR_PLATFORM` variable for details.
105
106 .. option:: --toolchain <path-to-file>
107
108  Specify the cross compiling toolchain file, equivalent to setting
109  :variable:`CMAKE_TOOLCHAIN_FILE` variable.
110
111 .. option:: --install-prefix <directory>
112
113  Specify the installation directory, used by the
114  :variable:`CMAKE_INSTALL_PREFIX` variable. Must be an absolute path.
115
116 .. option:: -Wno-dev
117
118  Suppress developer warnings.
119
120  Suppress warnings that are meant for the author of the
121  ``CMakeLists.txt`` files. By default this will also turn off
122  deprecation warnings.
123
124 .. option:: -Wdev
125
126  Enable developer warnings.
127
128  Enable warnings that are meant for the author of the ``CMakeLists.txt``
129  files. By default this will also turn on deprecation warnings.
130
131 .. option:: -Wdeprecated
132
133  Enable deprecated functionality warnings.
134
135  Enable warnings for usage of deprecated functionality, that are meant
136  for the author of the ``CMakeLists.txt`` files.
137
138 .. option:: -Wno-deprecated
139
140  Suppress deprecated functionality warnings.
141
142  Suppress warnings for usage of deprecated functionality, that are meant
143  for the author of the ``CMakeLists.txt`` files.
144
145 .. option:: -Werror=<what>
146
147  Treat CMake warnings as errors. ``<what>`` must be one of the following:
148
149  ``dev``
150    Make developer warnings errors.
151
152    Make warnings that are meant for the author of the ``CMakeLists.txt`` files
153    errors. By default this will also turn on deprecated warnings as errors.
154
155  ``deprecated``
156   Make deprecated macro and function warnings errors.
157
158   Make warnings for usage of deprecated macros and functions, that are meant
159   for the author of the ``CMakeLists.txt`` files, errors.
160
161 .. option:: -Wno-error=<what>
162
163  Do not treat CMake warnings as errors. ``<what>`` must be one of the following:
164
165  ``dev``
166   Make warnings that are meant for the author of the ``CMakeLists.txt`` files not
167   errors. By default this will also turn off deprecated warnings as errors.
168
169  ``deprecated``
170   Make warnings for usage of deprecated macros and functions, that are meant
171   for the author of the ``CMakeLists.txt`` files, not errors.