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 di‐
20 rectories 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 non-de‐
182 fault 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 CMAKE_ASM<DI‐
258 ALECT>_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 CUDAARCHS
328 New in version 3.20.
329
330
331 This is a CMake Environment Variable. Its initial value is taken from
332 the calling process environment.
333
334 Value used to initialize CMAKE_CUDA_ARCHITECTURES on the first configu‐
335 ration if it's not already defined. Subsequent runs will use the value
336 stored in the cache.
337
338 This is a semicolon-separated list of architectures as described in
339 CUDA_ARCHITECTURES.
340
341 CUDACXX
342 New in version 3.8.
343
344
345 This is a CMake Environment Variable. Its initial value is taken from
346 the calling process environment.
347
348 Preferred executable for compiling CUDA language files. Will only be
349 used by CMake on the first configuration to determine CUDA compiler,
350 after which the value for CUDA is stored in the cache as
351 CMAKE_CUDA_COMPILER. For any configuration run (including the first),
352 the environment variable will be ignored if the CMAKE_CUDA_COMPILER
353 variable is defined.
354
355 NOTE:
356 Options that are required to make the compiler work correctly can be
357 included; they can not be changed.
358
359 $ export CUDACXX="custom-compiler --arg1 --arg2"
360
361 CUDAFLAGS
362 New in version 3.8.
363
364
365 This is a CMake Environment Variable. Its initial value is taken from
366 the calling process environment.
367
368 Default compilation flags to be used when compiling CUDA files. Will
369 only be used by CMake on the first configuration to determine CUDA de‐
370 fault compilation flags, after which the value for CUDAFLAGS is stored
371 in the cache as CMAKE_CUDA_FLAGS. For any configuration run (including
372 the first), the environment variable will be ignored if the
373 CMAKE_CUDA_FLAGS variable is defined.
374
375 See also CMAKE_CUDA_FLAGS_INIT.
376
377 CUDAHOSTCXX
378 New in version 3.8.
379
380
381 This is a CMake Environment Variable. Its initial value is taken from
382 the calling process environment.
383
384 Preferred executable for compiling host code when compiling CUDA lan‐
385 guage files. Will only be used by CMake on the first configuration to
386 determine CUDA host compiler, after which the value for CUDAHOSTCXX is
387 stored in the cache as CMAKE_CUDA_HOST_COMPILER. For any configuration
388 run (including the first), the environment variable will be ignored if
389 the CMAKE_CUDA_HOST_COMPILER variable is defined.
390
391 This environment variable is primarily meant for use with projects that
392 enable CUDA as a first-class language.
393
394 New in version 3.13: The FindCUDA module will use this variable to ini‐
395 tialize its CUDA_HOST_COMPILER setting.
396
397
398 CXX
399 This is a CMake Environment Variable. Its initial value is taken from
400 the calling process environment.
401
402 Preferred executable for compiling CXX language files. Will only be
403 used by CMake on the first configuration to determine CXX compiler, af‐
404 ter which the value for CXX is stored in the cache as CMAKE_CXX_COM‐
405 PILER. For any configuration run (including the first), the environment
406 variable will be ignored if the CMAKE_CXX_COMPILER variable is defined.
407
408 NOTE:
409 Options that are required to make the compiler work correctly can be
410 included; they can not be changed.
411
412 $ export CXX="custom-compiler --arg1 --arg2"
413
414 CXXFLAGS
415 This is a CMake Environment Variable. Its initial value is taken from
416 the calling process environment.
417
418 Default compilation flags to be used when compiling CXX (C++) files.
419 Will only be used by CMake on the first configuration to determine CXX
420 default compilation flags, after which the value for CXXFLAGS is stored
421 in the cache as CMAKE_CXX_FLAGS. For any configuration run ( including
422 the first), the environment variable will be ignored if the
423 CMAKE_CXX_FLAGS variable is defined.
424
425 See also CMAKE_CXX_FLAGS_INIT.
426
427 FC
428 This is a CMake Environment Variable. Its initial value is taken from
429 the calling process environment.
430
431 Preferred executable for compiling Fortran language files. Will only be
432 used by CMake on the first configuration to determine Fortran compiler,
433 after which the value for Fortran is stored in the cache as CMAKE_For‐
434 tran_COMPILER. For any configuration run (including the first), the en‐
435 vironment variable will be ignored if the CMAKE_Fortran_COMPILER vari‐
436 able is defined.
437
438 NOTE:
439 Options that are required to make the compiler work correctly can be
440 included; they can not be changed.
441
442 $ export FC="custom-compiler --arg1 --arg2"
443
444 FFLAGS
445 This is a CMake Environment Variable. Its initial value is taken from
446 the calling process environment.
447
448 Default compilation flags to be used when compiling Fortran files. Will
449 only be used by CMake on the first configuration to determine Fortran
450 default compilation flags, after which the value for FFLAGS is stored
451 in the cache as CMAKE_Fortran_FLAGS. For any configuration run (includ‐
452 ing the first), the environment variable will be ignored if the
453 CMAKE_Fortran_FLAGS variable is defined.
454
455 See also CMAKE_Fortran_FLAGS_INIT.
456
457 ISPC
458 New in version 3.19.
459
460
461 This is a CMake Environment Variable. Its initial value is taken from
462 the calling process environment.
463
464 Preferred executable for compiling ISPC language files. Will only be
465 used by CMake on the first configuration to determine ISPC compiler,
466 after which the value for ISPC is stored in the cache as
467 CMAKE_ISPC_COMPILER. For any configuration run (including the first),
468 the environment variable will be ignored if the CMAKE_ISPC_COMPILER
469 variable is defined.
470
471 ISPCFLAGS
472 New in version 3.19.
473
474
475 This is a CMake Environment Variable. Its initial value is taken from
476 the calling process environment.
477
478 Default compilation flags to be used when compiling ISPC files. Will
479 only be used by CMake on the first configuration to determine ISPC de‐
480 fault compilation flags, after which the value for ISPCFLAGS is stored
481 in the cache as CMAKE_ISPC_FLAGS. For any configuration run (including
482 the first), the environment variable will be ignored if the
483 CMAKE_ISPC_FLAGS variable is defined.
484
485 See also CMAKE_ISPC_FLAGS_INIT.
486
487 OBJC
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 OBJC language files. Will only be
495 used by CMake on the first configuration to determine OBJC compiler,
496 after which the value for OBJC is stored in the cache as
497 CMAKE_OBJC_COMPILER. For any configuration run (including the first),
498 the environment variable will be ignored if the CMAKE_OBJC_COMPILER
499 variable is defined.
500
501 If OBJC is not defined, the CC environment variable will be checked in‐
502 stead.
503
504 OBJCXX
505 New in version 3.16.7.
506
507
508 This is a CMake Environment Variable. Its initial value is taken from
509 the calling process environment.
510
511 Preferred executable for compiling OBJCXX language files. Will only be
512 used by CMake on the first configuration to determine OBJCXX compiler,
513 after which the value for OBJCXX is stored in the cache as CMAKE_OB‐
514 JCXX_COMPILER. For any configuration run (including the first), the en‐
515 vironment variable will be ignored if the CMAKE_OBJCXX_COMPILER vari‐
516 able is defined.
517
518 If OBJCXX is not defined, the CXX environment variable will be checked
519 instead.
520
521 RC
522 This is a CMake Environment Variable. Its initial value is taken from
523 the calling process environment.
524
525 Preferred executable for compiling resource files. Will only be used by
526 CMake on the first configuration to determine resource compiler, after
527 which the value for RC is stored in the cache as CMAKE_RC_COMPILER. For
528 any configuration run (including the first), the environment variable
529 will be ignored if the CMAKE_RC_COMPILER variable is defined.
530
531 NOTE:
532 Options that are required to make the compiler work correctly can be
533 included; they can not be changed.
534
535 $ export RC="custom-compiler --arg1 --arg2"
536
537 RCFLAGS
538 This is a CMake Environment Variable. Its initial value is taken from
539 the calling process environment.
540
541 Default compilation flags to be used when compiling resource files.
542 Will only be used by CMake on the first configuration to determine re‐
543 source default compilation flags, after which the value for RCFLAGS is
544 stored in the cache as CMAKE_RC_FLAGS. For any configuration run (in‐
545 cluding the first), the environment variable will be ignored if the
546 CMAKE_RC_FLAGS variable is defined.
547
548 See also CMAKE_RC_FLAGS_INIT.
549
550 SWIFTC
551 New in version 3.15.
552
553
554 This is a CMake Environment Variable. Its initial value is taken from
555 the calling process environment.
556
557 Preferred executable for compiling Swift language files. Will only be
558 used by CMake on the first configuration to determine Swift compiler,
559 after which the value for SWIFTC is stored in the cache as
560 CMAKE_Swift_COMPILER. For any configuration run (including the first),
561 the environment variable will be ignored if the CMAKE_Swift_COMPILER
562 variable is defined.
563
564 NOTE:
565 Options that are required to make the compiler work correctly can be
566 included; they can not be changed.
567
568 $ export SWIFTC="custom-compiler --arg1 --arg2"
569
571 CTEST_INTERACTIVE_DEBUG_MODE
572 This is a CMake Environment Variable. Its initial value is taken from
573 the calling process environment.
574
575 Environment variable that will exist and be set to 1 when a test exe‐
576 cuted by ctest(1) is run in interactive mode.
577
578 CTEST_OUTPUT_ON_FAILURE
579 This is a CMake Environment Variable. Its initial value is taken from
580 the calling process environment.
581
582 Boolean environment variable that controls if the output should be
583 logged for failed tests. Set the value to 1, True, or ON to enable out‐
584 put on failure. See ctest(1) for more information on controlling out‐
585 put of failed tests.
586
587 CTEST_PARALLEL_LEVEL
588 This is a CMake Environment Variable. Its initial value is taken from
589 the calling process environment.
590
591 Specify the number of tests for CTest to run in parallel. See ctest(1)
592 for more information on parallel test execution.
593
594 CTEST_PROGRESS_OUTPUT
595 New in version 3.13.
596
597
598 This is a CMake Environment Variable. Its initial value is taken from
599 the calling process environment.
600
601 Boolean environment variable that affects how ctest command output re‐
602 ports overall progress. When set to 1, TRUE, ON or anything else that
603 evaluates to boolean true, progress is reported by repeatedly updating
604 the same line. This greatly reduces the overall verbosity, but is only
605 supported when output is sent directly to a terminal. If the environ‐
606 ment variable is not set or has a value that evaluates to false, output
607 is reported normally with each test having its own start and end lines
608 logged to the output.
609
610 The --progress option to ctest overrides this environment variable if
611 both are given.
612
613 CTEST_USE_LAUNCHERS_DEFAULT
614 This is a CMake Environment Variable. Its initial value is taken from
615 the calling process environment.
616
617 Initializes the CTEST_USE_LAUNCHERS variable if not already defined.
618
619 DASHBOARD_TEST_FROM_CTEST
620 This is a CMake Environment Variable. Its initial value is taken from
621 the calling process environment.
622
623 Environment variable that will exist when a test executed by ctest(1)
624 is run in non-interactive mode. The value will be equal to CMAKE_VER‐
625 SION.
626
628 CCMAKE_COLORS
629 New in version 3.18.
630
631
632 Determines what colors are used by the CMake curses interface, when run
633 on a terminal that supports colors. The syntax follows the same con‐
634 ventions as LS_COLORS; that is, a list of key/value pairs separated by
635 :.
636
637 Keys are a single letter corresponding to a CMake cache variable type:
638
639 • s: A STRING.
640
641 • p: A FILEPATH.
642
643 • c: A value which has an associated list of choices.
644
645 • y: A BOOL which has a true-like value (e.g. ON, YES).
646
647 • n: A BOOL which has a false-like value (e.g. OFF, NO).
648
649 Values are an integer number that specifies what color to use. 0 is
650 black (you probably don't want to use that). Others are determined by
651 your terminal's color support. Most (color) terminals will support at
652 least 8 or 16 colors. Some will support up to 256 colors. The colors
653 will likely match this chart, although the first 16 colors may match
654 the original CGA color palette. (Many modern terminal emulators also
655 allow their color palette, at least for the first 16 colors, to be con‐
656 figured by the user.)
657
658 Note that fairly minimal checking is done for bad colors (although a
659 value higher than what curses believes your terminal supports will be
660 silently ignored) or bad syntax.
661
662 For example:
663
664 CCMAKE_COLORS='s=39:p=220:c=207:n=196:y=46'
665
667 2000-2021 Kitware, Inc. and Contributors
668
669
670
671
6723.20.3 May 30, 2021 CMAKE-ENV-VARIABLES(7)