1CMAKE-ENV-VARIABLES(7) CMake CMAKE-ENV-VARIABLES(7)
2
3
4
6 cmake-env-variables - CMake Environment Variables Reference
7
8 This page lists environment variables that have special meaning to
9 CMake.
10
11 For general information on environment variables, see the Environment
12 Variables section in the cmake-language manual.
13
15 CMAKE_PREFIX_PATH
16 This is a CMake Environment Variable. Its initial value is taken from
17 the calling process environment.
18
19 The CMAKE_PREFIX_PATH environment variable may be set to a list of
20 directories specifying installation prefixes to be searched by the
21 find_package(), find_program(), find_library(), find_file(), and
22 find_path() commands. Each command will add appropriate subdirectories
23 (like bin, lib, or include) as specified in its own documentation.
24
25 This variable may hold a single prefix or a list of prefixes separated
26 by : on UNIX or ; on Windows (the same as the PATH environment variable
27 convention on those platforms).
28
29 See also the CMAKE_PREFIX_PATH CMake variable.
30
32 CMAKE_APPLE_SILICON_PROCESSOR
33 New in version 3.19.2.
34
35
36 This is a CMake Environment Variable. Its initial value is taken from
37 the calling process environment.
38
39 On Apple Silicon hosts running macOS, set this environment variable to
40 tell CMake what architecture to use for CMAKE_HOST_SYSTEM_PROCESSOR.
41 The value must be either arm64 or x86_64.
42
43 The CMAKE_APPLE_SILICON_PROCESSOR normal variable, if set, overrides
44 this environment variable.
45
46 CMAKE_BUILD_PARALLEL_LEVEL
47 New in version 3.12.
48
49
50 This is a CMake Environment Variable. Its initial value is taken from
51 the calling process environment.
52
53 Specifies the maximum number of concurrent processes to use when build‐
54 ing using the cmake --build command line Build Tool Mode.
55
56 If this variable is defined empty the native build tool’s default num‐
57 ber is used.
58
59 CMAKE_CONFIG_TYPE
60 This is a CMake Environment Variable. Its initial value is taken from
61 the calling process environment.
62
63 The default build configuration for Build Tool Mode and ctest build
64 handler when there is no explicit configuration given.
65
66 CMAKE_EXPORT_COMPILE_COMMANDS
67 New in version 3.17.
68
69
70 This is a CMake Environment Variable. Its initial value is taken from
71 the calling process environment.
72
73 The default value for CMAKE_EXPORT_COMPILE_COMMANDS when there is no
74 explicit configuration given on the first run while creating a new
75 build tree. On later runs in an existing build tree the value persists
76 in the cache as CMAKE_EXPORT_COMPILE_COMMANDS.
77
78 CMAKE_GENERATOR
79 New in version 3.15.
80
81
82 This is a CMake Environment Variable. Its initial value is taken from
83 the calling process environment.
84
85 Specifies the CMake default generator to use when no generator is sup‐
86 plied with -G. If the provided value doesn’t name a generator known by
87 CMake, the internal default is used. Either way the resulting genera‐
88 tor selection is stored in the CMAKE_GENERATOR variable.
89
90 Some generators may be additionally configured using the environment
91 variables:
92
93 · CMAKE_GENERATOR_PLATFORM
94
95 · CMAKE_GENERATOR_TOOLSET
96
97 · CMAKE_GENERATOR_INSTANCE
98
99 CMAKE_GENERATOR_INSTANCE
100 New in version 3.15.
101
102
103 This is a CMake Environment Variable. Its initial value is taken from
104 the calling process environment.
105
106 Default value for CMAKE_GENERATOR_INSTANCE if no Cache entry is
107 present. This value is only applied if CMAKE_GENERATOR is set.
108
109 CMAKE_GENERATOR_PLATFORM
110 New in version 3.15.
111
112
113 This is a CMake Environment Variable. Its initial value is taken from
114 the calling process environment.
115
116 Default value for CMAKE_GENERATOR_PLATFORM if no Cache entry is present
117 and no value is specified by cmake(1) -A option. This value is only
118 applied if CMAKE_GENERATOR is set.
119
120 CMAKE_GENERATOR_TOOLSET
121 New in version 3.15.
122
123
124 This is a CMake Environment Variable. Its initial value is taken from
125 the calling process environment.
126
127 Default value for CMAKE_GENERATOR_TOOLSET if no Cache entry is present
128 and no value is specified by cmake(1) -T option. This value is only
129 applied if CMAKE_GENERATOR is set.
130
131 CMAKE_<LANG>_COMPILER_LAUNCHER
132 New in version 3.17.
133
134
135 This is a CMake Environment Variable. Its initial value is taken from
136 the calling process environment.
137
138 Default compiler launcher to use for the specified language. Will only
139 be used by CMake to initialize the variable on the first configuration.
140 Afterwards, it is available through the cache setting of the variable
141 of the same name. For any configuration run (including the first), the
142 environment variable will be ignored if the CMAKE_<LANG>_COM‐
143 PILER_LAUNCHER variable is defined.
144
145 CMAKE_MSVCIDE_RUN_PATH
146 This is a CMake Environment Variable. Its initial value is taken from
147 the calling process environment.
148
149 Extra PATH locations for custom commands when using Visual Studio 9
150 2008 (or above) generators.
151
152 The CMAKE_MSVCIDE_RUN_PATH environment variable sets the default value
153 for the CMAKE_MSVCIDE_RUN_PATH variable if not already explicitly set.
154
155 CMAKE_NO_VERBOSE
156 New in version 3.14.
157
158
159 Disables verbose output from CMake when VERBOSE environment variable is
160 set.
161
162 Only your build tool of choice will still print verbose output when you
163 start to actually build your project.
164
165 CMAKE_OSX_ARCHITECTURES
166 This is a CMake Environment Variable. Its initial value is taken from
167 the calling process environment.
168
169 Target specific architectures for macOS.
170
171 The CMAKE_OSX_ARCHITECTURES environment variable sets the default value
172 for the CMAKE_OSX_ARCHITECTURES variable. See OSX_ARCHITECTURES for
173 more information.
174
175 DESTDIR
176 This is a CMake Environment Variable. Its initial value is taken from
177 the calling process environment.
178
179 On UNIX one can use the DESTDIR mechanism in order to relocate the
180 whole installation. DESTDIR means DESTination DIRectory. It is com‐
181 monly used by makefile users in order to install software at
182 non-default location. It is usually invoked like this:
183
184 make DESTDIR=/home/john install
185
186 which will install the concerned software using the installation pre‐
187 fix, e.g. /usr/local prepended with the DESTDIR value which finally
188 gives /home/john/usr/local.
189
190 WARNING: DESTDIR may not be used on Windows because installation prefix
191 usually contains a drive letter like in C:/Program Files which cannot
192 be prepended with some other prefix.
193
194 LDFLAGS
195 This is a CMake Environment Variable. Its initial value is taken from
196 the calling process environment.
197
198 Will only be used by CMake on the first configuration to determine the
199 default linker flags, after which the value for LDFLAGS is stored in
200 the cache as CMAKE_EXE_LINKER_FLAGS_INIT,
201 CMAKE_SHARED_LINKER_FLAGS_INIT, and CMAKE_MODULE_LINKER_FLAGS_INIT. For
202 any configuration run (including the first), the environment variable
203 will be ignored if the equivalent CMAKE_<TYPE>_LINKER_FLAGS_INIT vari‐
204 able is defined.
205
206 MACOSX_DEPLOYMENT_TARGET
207 This is a CMake Environment Variable. Its initial value is taken from
208 the calling process environment.
209
210 Specify the minimum version of macOS on which the target binaries are
211 to be deployed.
212
213 The MACOSX_DEPLOYMENT_TARGET environment variable sets the default
214 value for the CMAKE_OSX_DEPLOYMENT_TARGET variable.
215
216 <PackageName>_ROOT
217 New in version 3.12.
218
219
220 This is a CMake Environment Variable. Its initial value is taken from
221 the calling process environment.
222
223 Calls to find_package(<PackageName>) will search in prefixes specified
224 by the <PackageName>_ROOT environment variable, where <PackageName> is
225 the name given to the find_package() call and _ROOT is literal. For
226 example, find_package(Foo) will search prefixes specified in the
227 Foo_ROOT environment variable (if set). See policy CMP0074.
228
229 This variable may hold a single prefix or a list of prefixes separated
230 by : on UNIX or ; on Windows (the same as the PATH environment variable
231 convention on those platforms).
232
233 See also the <PackageName>_ROOT CMake variable.
234
235 VERBOSE
236 New in version 3.14.
237
238
239 Activates verbose output from CMake and your build tools of choice when
240 you start to actually build your project.
241
242 Note that any given value is ignored. It’s just checked for existence.
243
244 See also Build Tool Mode and CMAKE_NO_VERBOSE environment variable
245
247 ASM<DIALECT>
248 This is a CMake Environment Variable. Its initial value is taken from
249 the calling process environment.
250
251 Preferred executable for compiling a specific dialect of assembly lan‐
252 guage files. ASM<DIALECT> can be ASM, ASM_NASM (Netwide Assembler),
253 ASM_MASM (Microsoft Assembler) or ASM-ATT (Assembler AT&T). Will only
254 be used by CMake on the first configuration to determine ASM<DIALECT>
255 compiler, after which the value for ASM<DIALECT> is stored in the cache
256 as CMAKE_ASM<DIALECT>_COMPILER. For subsequent configuration runs, the
257 environment variable will be ignored in favor of
258 CMAKE_ASM<DIALECT>_COMPILER.
259
260 NOTE:
261 Options that are required to make the compiler work correctly can be
262 included; they can not be changed.
263
264 $ export ASM="custom-compiler --arg1 --arg2"
265
266 ASM<DIALECT>FLAGS
267 This is a CMake Environment Variable. Its initial value is taken from
268 the calling process environment.
269
270 Default compilation flags to be used when compiling a specific dialect
271 of an assembly language. ASM<DIALECT>FLAGS can be ASMFLAGS, ASM_NASM‐
272 FLAGS, ASM_MASMFLAGS or ASM-ATTFLAGS. Will only be used by CMake on the
273 first configuration to determine ASM_<DIALECT> default compilation
274 flags, after which the value for ASM<DIALECT>FLAGS is stored in the
275 cache as CMAKE_ASM<DIALECT>_FLAGS <CMAKE_<LANG>_FLAGS>. For any con‐
276 figuration run (including the first), the environment variable will be
277 ignored, if the CMAKE_ASM<DIALECT>_FLAGS <CMAKE_<LANG>_FLAGS> variable
278 is defined.
279
280 See also CMAKE_ASM<DIALECT>_FLAGS_INIT.
281
282 CC
283 This is a CMake Environment Variable. Its initial value is taken from
284 the calling process environment.
285
286 Preferred executable for compiling C language files. Will only be used
287 by CMake on the first configuration to determine C compiler, after
288 which the value for CC is stored in the cache as CMAKE_C_COMPILER. For
289 any configuration run (including the first), the environment variable
290 will be ignored if the CMAKE_C_COMPILER variable is defined.
291
292 NOTE:
293 Options that are required to make the compiler work correctly can be
294 included; they can not be changed.
295
296 $ export CC="custom-compiler --arg1 --arg2"
297
298 CFLAGS
299 This is a CMake Environment Variable. Its initial value is taken from
300 the calling process environment.
301
302 Default compilation flags to be used when compiling C files. Will only
303 be used by CMake on the first configuration to determine CC default
304 compilation flags, after which the value for CFLAGS is stored in the
305 cache as CMAKE_C_FLAGS. For any configuration run (including the
306 first), the environment variable will be ignored if the CMAKE_C_FLAGS
307 variable is defined.
308
309 See also CMAKE_C_FLAGS_INIT.
310
311 CSFLAGS
312 New in version 3.9.2.
313
314
315 This is a CMake Environment Variable. Its initial value is taken from
316 the calling process environment.
317
318 Default compilation flags to be used when compiling CSharp files. Will
319 only be used by CMake on the first configuration to determine CSharp
320 default compilation flags, after which the value for CSFLAGS is stored
321 in the cache as CMAKE_CSharp_FLAGS. For any configuration run (includ‐
322 ing the first), the environment variable will be ignored if the
323 CMAKE_CSharp_FLAGS variable is defined.
324
325 See also CMAKE_CSharp_FLAGS_INIT.
326
327 CUDACXX
328 New in version 3.8.
329
330
331 This is a CMake Environment Variable. Its initial value is taken from
332 the calling process environment.
333
334 Preferred executable for compiling CUDA language files. Will only be
335 used by CMake on the first configuration to determine CUDA compiler,
336 after which the value for CUDA is stored in the cache as
337 CMAKE_CUDA_COMPILER. For any configuration run (including the first),
338 the environment variable will be ignored if the CMAKE_CUDA_COMPILER
339 variable is defined.
340
341 NOTE:
342 Options that are required to make the compiler work correctly can be
343 included; they can not be changed.
344
345 $ export CUDACXX="custom-compiler --arg1 --arg2"
346
347 CUDAFLAGS
348 New in version 3.8.
349
350
351 This is a CMake Environment Variable. Its initial value is taken from
352 the calling process environment.
353
354 Default compilation flags to be used when compiling CUDA files. Will
355 only be used by CMake on the first configuration to determine CUDA
356 default compilation flags, after which the value for CUDAFLAGS is
357 stored in the cache as CMAKE_CUDA_FLAGS. For any configuration run
358 (including the first), the environment variable will be ignored if the
359 CMAKE_CUDA_FLAGS variable is defined.
360
361 See also CMAKE_CUDA_FLAGS_INIT.
362
363 CUDAHOSTCXX
364 New in version 3.8.
365
366
367 This is a CMake Environment Variable. Its initial value is taken from
368 the calling process environment.
369
370 Preferred executable for compiling host code when compiling CUDA lan‐
371 guage files. Will only be used by CMake on the first configuration to
372 determine CUDA host compiler, after which the value for CUDAHOSTCXX is
373 stored in the cache as CMAKE_CUDA_HOST_COMPILER. For any configuration
374 run (including the first), the environment variable will be ignored if
375 the CMAKE_CUDA_HOST_COMPILER variable is defined.
376
377 This environment variable is primarily meant for use with projects that
378 enable CUDA as a first-class language. The FindCUDA module will also
379 use it to initialize its CUDA_HOST_COMPILER setting.
380
381 CXX
382 This is a CMake Environment Variable. Its initial value is taken from
383 the calling process environment.
384
385 Preferred executable for compiling CXX language files. Will only be
386 used by CMake on the first configuration to determine CXX compiler,
387 after which the value for CXX is stored in the cache as CMAKE_CXX_COM‐
388 PILER. For any configuration run (including the first), the environment
389 variable will be ignored if the CMAKE_CXX_COMPILER variable is defined.
390
391 NOTE:
392 Options that are required to make the compiler work correctly can be
393 included; they can not be changed.
394
395 $ export CXX="custom-compiler --arg1 --arg2"
396
397 CXXFLAGS
398 This is a CMake Environment Variable. Its initial value is taken from
399 the calling process environment.
400
401 Default compilation flags to be used when compiling CXX (C++) files.
402 Will only be used by CMake on the first configuration to determine CXX
403 default compilation flags, after which the value for CXXFLAGS is stored
404 in the cache as CMAKE_CXX_FLAGS. For any configuration run ( including
405 the first), the environment variable will be ignored if the
406 CMAKE_CXX_FLAGS variable is defined.
407
408 See also CMAKE_CXX_FLAGS_INIT.
409
410 FC
411 This is a CMake Environment Variable. Its initial value is taken from
412 the calling process environment.
413
414 Preferred executable for compiling Fortran language files. Will only be
415 used by CMake on the first configuration to determine Fortran compiler,
416 after which the value for Fortran is stored in the cache as CMAKE_For‐
417 tran_COMPILER. For any configuration run (including the first), the
418 environment variable will be ignored if the CMAKE_Fortran_COMPILER
419 variable is defined.
420
421 NOTE:
422 Options that are required to make the compiler work correctly can be
423 included; they can not be changed.
424
425 $ export FC="custom-compiler --arg1 --arg2"
426
427 FFLAGS
428 This is a CMake Environment Variable. Its initial value is taken from
429 the calling process environment.
430
431 Default compilation flags to be used when compiling Fortran files. Will
432 only be used by CMake on the first configuration to determine Fortran
433 default compilation flags, after which the value for FFLAGS is stored
434 in the cache as CMAKE_Fortran_FLAGS. For any configuration run (includ‐
435 ing the first), the environment variable will be ignored if the
436 CMAKE_Fortran_FLAGS variable is defined.
437
438 See also CMAKE_Fortran_FLAGS_INIT.
439
440 ISPC
441 New in version 3.19.
442
443
444 This is a CMake Environment Variable. Its initial value is taken from
445 the calling process environment.
446
447 Preferred executable for compiling ISPC language files. Will only be
448 used by CMake on the first configuration to determine ISPC compiler,
449 after which the value for ISPC is stored in the cache as
450 CMAKE_ISPC_COMPILER. For any configuration run (including the first),
451 the environment variable will be ignored if the CMAKE_ISPC_COMPILER
452 variable is defined.
453
454 ISPCFLAGS
455 New in version 3.19.
456
457
458 This is a CMake Environment Variable. Its initial value is taken from
459 the calling process environment.
460
461 Default compilation flags to be used when compiling ISPC files. Will
462 only be used by CMake on the first configuration to determine ISPC
463 default compilation flags, after which the value for ISPCFLAGS is
464 stored in the cache as CMAKE_ISPC_FLAGS. For any configuration run
465 (including the first), the environment variable will be ignored if the
466 CMAKE_ISPC_FLAGS variable is defined.
467
468 See also CMAKE_ISPC_FLAGS_INIT.
469
470 OBJC
471 New in version 3.16.7.
472
473
474 This is a CMake Environment Variable. Its initial value is taken from
475 the calling process environment.
476
477 Preferred executable for compiling OBJC language files. Will only be
478 used by CMake on the first configuration to determine OBJC compiler,
479 after which the value for OBJC is stored in the cache as
480 CMAKE_OBJC_COMPILER. For any configuration run (including the first),
481 the environment variable will be ignored if the CMAKE_OBJC_COMPILER
482 variable is defined.
483
484 If OBJC is not defined, the CC environment variable will be checked
485 instead.
486
487 OBJCXX
488 New in version 3.16.7.
489
490
491 This is a CMake Environment Variable. Its initial value is taken from
492 the calling process environment.
493
494 Preferred executable for compiling OBJCXX language files. Will only be
495 used by CMake on the first configuration to determine OBJCXX compiler,
496 after which the value for OBJCXX is stored in the cache as
497 CMAKE_OBJCXX_COMPILER. For any configuration run (including the first),
498 the environment variable will be ignored if the CMAKE_OBJCXX_COMPILER
499 variable is defined.
500
501 If OBJCXX is not defined, the CXX environment variable will be checked
502 instead.
503
504 RC
505 This is a CMake Environment Variable. Its initial value is taken from
506 the calling process environment.
507
508 Preferred executable for compiling resource files. Will only be used by
509 CMake on the first configuration to determine resource compiler, after
510 which the value for RC is stored in the cache as CMAKE_RC_COMPILER. For
511 any configuration run (including the first), the environment variable
512 will be ignored if the CMAKE_RC_COMPILER variable is defined.
513
514 NOTE:
515 Options that are required to make the compiler work correctly can be
516 included; they can not be changed.
517
518 $ export RC="custom-compiler --arg1 --arg2"
519
520 RCFLAGS
521 This is a CMake Environment Variable. Its initial value is taken from
522 the calling process environment.
523
524 Default compilation flags to be used when compiling resource files.
525 Will only be used by CMake on the first configuration to determine
526 resource default compilation flags, after which the value for RCFLAGS
527 is stored in the cache as CMAKE_RC_FLAGS. For any configuration run
528 (including the first), the environment variable will be ignored if the
529 CMAKE_RC_FLAGS variable is defined.
530
531 See also CMAKE_RC_FLAGS_INIT.
532
533 SWIFTC
534 New in version 3.15.
535
536
537 This is a CMake Environment Variable. Its initial value is taken from
538 the calling process environment.
539
540 Preferred executable for compiling Swift language files. Will only be
541 used by CMake on the first configuration to determine Swift compiler,
542 after which the value for SWIFTC is stored in the cache as
543 CMAKE_Swift_COMPILER. For any configuration run (including the first),
544 the environment variable will be ignored if the CMAKE_Swift_COMPILER
545 variable is defined.
546
547 NOTE:
548 Options that are required to make the compiler work correctly can be
549 included; they can not be changed.
550
551 $ export SWIFTC="custom-compiler --arg1 --arg2"
552
554 CTEST_INTERACTIVE_DEBUG_MODE
555 This is a CMake Environment Variable. Its initial value is taken from
556 the calling process environment.
557
558 Environment variable that will exist and be set to 1 when a test exe‐
559 cuted by ctest(1) is run in interactive mode.
560
561 CTEST_OUTPUT_ON_FAILURE
562 This is a CMake Environment Variable. Its initial value is taken from
563 the calling process environment.
564
565 Boolean environment variable that controls if the output should be
566 logged for failed tests. Set the value to 1, True, or ON to enable out‐
567 put on failure. See ctest(1) for more information on controlling out‐
568 put of failed tests.
569
570 CTEST_PARALLEL_LEVEL
571 This is a CMake Environment Variable. Its initial value is taken from
572 the calling process environment.
573
574 Specify the number of tests for CTest to run in parallel. See ctest(1)
575 for more information on parallel test execution.
576
577 CTEST_PROGRESS_OUTPUT
578 New in version 3.13.
579
580
581 This is a CMake Environment Variable. Its initial value is taken from
582 the calling process environment.
583
584 Boolean environment variable that affects how ctest command output
585 reports overall progress. When set to 1, TRUE, ON or anything else
586 that evaluates to boolean true, progress is reported by repeatedly
587 updating the same line. This greatly reduces the overall verbosity,
588 but is only supported when output is sent directly to a terminal. If
589 the environment variable is not set or has a value that evaluates to
590 false, output is reported normally with each test having its own start
591 and end lines logged to the output.
592
593 The --progress option to ctest overrides this environment variable if
594 both are given.
595
596 CTEST_USE_LAUNCHERS_DEFAULT
597 This is a CMake Environment Variable. Its initial value is taken from
598 the calling process environment.
599
600 Initializes the CTEST_USE_LAUNCHERS variable if not already defined.
601
602 DASHBOARD_TEST_FROM_CTEST
603 This is a CMake Environment Variable. Its initial value is taken from
604 the calling process environment.
605
606 Environment variable that will exist when a test executed by ctest(1)
607 is run in non-interactive mode. The value will be equal to CMAKE_VER‐
608 SION.
609
611 CCMAKE_COLORS
612 New in version 3.18.
613
614
615 Determines what colors are used by the CMake curses interface, when run
616 on a terminal that supports colors. The syntax follows the same con‐
617 ventions as LS_COLORS; that is, a list of key/value pairs separated by
618 :.
619
620 Keys are a single letter corresponding to a CMake cache variable type:
621
622 · s: A STRING.
623
624 · p: A FILEPATH.
625
626 · c: A value which has an associated list of choices.
627
628 · y: A BOOL which has a true-like value (e.g. ON, YES).
629
630 · n: A BOOL which has a false-like value (e.g. OFF, NO).
631
632 Values are an integer number that specifies what color to use. 0 is
633 black (you probably don’t want to use that). Others are determined by
634 your terminal’s color support. Most (color) terminals will support at
635 least 8 or 16 colors. Some will support up to 256 colors. The colors
636 will likely match this chart, although the first 16 colors may match
637 the original CGA color palette. (Many modern terminal emulators also
638 allow their color palette, at least for the first 16 colors, to be con‐
639 figured by the user.)
640
641 Note that fairly minimal checking is done for bad colors (although a
642 value higher than what curses believes your terminal supports will be
643 silently ignored) or bad syntax.
644
645 For example:
646
647 CCMAKE_COLORS='s=39:p=220:c=207:n=196:y=46'
648
650 2000-2021 Kitware, Inc. and Contributors
651
652
653
654
6553.19.7 Mar 15, 2021 CMAKE-ENV-VARIABLES(7)