cmake-env-variables - CMake Environment Variables Reference This page lists environment variables that have special meaning to CMake. For general information on environment variables, see the Environment Variables section in the cmake-language manual.
Please see following description for synopsis
CMAKE-ENV-VARIABLES(7) CMake CMAKE-ENV-VARIABLES(7)
NAME
cmake-env-variables - CMake Environment Variables Reference
This page lists environment variables that have special meaning to
CMake.
For general information on environment variables, see the Environment
Variables section in the cmake-language manual.
ENVIRONMENT VARIABLES THAT CHANGE BEHAVIOR
CMAKE_PREFIX_PATH
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
The CMAKE_PREFIX_PATH environment variable may be set to a list of
directories specifying installation prefixes to be searched by the
find_package(), find_program(), find_library(), find_file(), and
find_path() commands. Each command will add appropriate subdirectories
(like bin, lib, or include) as specified in its own documentation.
This variable may hold a single prefix or a list of prefixes separated
by : on UNIX or ; on Windows (the same as the PATH environment variable
convention on those platforms).
See also the CMAKE_PREFIX_PATH CMake variable.
ENVIRONMENT VARIABLES THAT CONTROL THE BUILD
CMAKE_APPLE_SILICON_PROCESSOR
New in version 3.19.2.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
On Apple Silicon hosts running macOS, set this environment variable to
tell CMake what architecture to use for CMAKE_HOST_SYSTEM_PROCESSOR.
The value must be either arm64 or x86_64.
The CMAKE_APPLE_SILICON_PROCESSOR normal variable, if set, overrides
this environment variable.
CMAKE_BUILD_PARALLEL_LEVEL
New in version 3.12.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Specifies the maximum number of concurrent processes to use when build-
ing using the cmake --build command line Build Tool Mode.
If this variable is defined empty the native build tool's default num-
ber is used.
CMAKE_CONFIG_TYPE
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
The default build configuration for Build Tool Mode and ctest build
handler when there is no explicit configuration given.
CMAKE_EXPORT_COMPILE_COMMANDS
New in version 3.17.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
The default value for CMAKE_EXPORT_COMPILE_COMMANDS when there is no
explicit configuration given on the first run while creating a new
build tree. On later runs in an existing build tree the value persists
in the cache as CMAKE_EXPORT_COMPILE_COMMANDS.
CMAKE_GENERATOR
New in version 3.15.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Specifies the CMake default generator to use when no generator is sup-
plied with -G. If the provided value doesn't name a generator known by
CMake, the internal default is used. Either way the resulting genera-
tor selection is stored in the CMAKE_GENERATOR variable.
Some generators may be additionally configured using the environment
variables:
o CMAKE_GENERATOR_PLATFORM
o CMAKE_GENERATOR_TOOLSET
o CMAKE_GENERATOR_INSTANCE
CMAKE_GENERATOR_INSTANCE
New in version 3.15.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default value for CMAKE_GENERATOR_INSTANCE if no Cache entry is
present. This value is only applied if CMAKE_GENERATOR is set.
CMAKE_GENERATOR_PLATFORM
New in version 3.15.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default value for CMAKE_GENERATOR_PLATFORM if no Cache entry is present
and no value is specified by cmake(1) -A option. This value is only
applied if CMAKE_GENERATOR is set.
CMAKE_GENERATOR_TOOLSET
New in version 3.15.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default value for CMAKE_GENERATOR_TOOLSET if no Cache entry is present
and no value is specified by cmake(1) -T option. This value is only
applied if CMAKE_GENERATOR is set.
CMAKE_<LANG>_COMPILER_LAUNCHER
New in version 3.17.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default compiler launcher to use for the specified language. Will only
be used by CMake to initialize the variable on the first configuration.
Afterwards, it is available through the cache setting of the variable
of the same name. For any configuration run (including the first), the
environment variable will be ignored if the CMAKE_<LANG>_COM-
PILER_LAUNCHER variable is defined.
CMAKE_<LANG>_LINKER_LAUNCHER
New in version 3.21.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default launcher to use when linking a target of the specified lan-
guage. Will only be used by CMake to initialize the variable on the
first configuration. Afterwards, it is available through the cache
setting of the variable of the same name. For any configuration run
(including the first), the environment variable will be ignored if the
CMAKE_<LANG>_LINKER_LAUNCHER variable is defined.
CMAKE_MSVCIDE_RUN_PATH
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Extra PATH locations for custom commands when using Visual Studio 9
2008 (or above) generators.
The CMAKE_MSVCIDE_RUN_PATH environment variable sets the default value
for the CMAKE_MSVCIDE_RUN_PATH variable if not already explicitly set.
CMAKE_NO_VERBOSE
New in version 3.14.
Disables verbose output from CMake when VERBOSE environment variable is
set.
Only your build tool of choice will still print verbose output when you
start to actually build your project.
CMAKE_OSX_ARCHITECTURES
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Target specific architectures for macOS.
The CMAKE_OSX_ARCHITECTURES environment variable sets the default value
for the CMAKE_OSX_ARCHITECTURES variable. See OSX_ARCHITECTURES for
more information.
CMAKE_TOOLCHAIN_FILE
New in version 3.21.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
The CMAKE_TOOLCHAIN_FILE environment variable specifies a default value
for the CMAKE_TOOLCHAIN_FILE variable when there is no explicit config-
uration given on the first run while creating a new build tree. On
later runs in an existing build tree the value persists in the cache as
CMAKE_TOOLCHAIN_FILE.
DESTDIR
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
On UNIX one can use the DESTDIR mechanism in order to relocate the
whole installation. DESTDIR means DESTination DIRectory. It is com-
monly used by makefile users in order to install software at
non-default location. It is usually invoked like this:
make DESTDIR=/home/john install
which will install the concerned software using the installation pre-
fix, e.g. /usr/local prepended with the DESTDIR value which finally
gives /home/john/usr/local.
WARNING: DESTDIR may not be used on Windows because installation prefix
usually contains a drive letter like in C:/Program Files which cannot
be prepended with some other prefix.
LDFLAGS
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Will only be used by CMake on the first configuration to determine the
default linker flags, after which the value for LDFLAGS is stored in
the cache as CMAKE_EXE_LINKER_FLAGS_INIT,
CMAKE_SHARED_LINKER_FLAGS_INIT, and CMAKE_MODULE_LINKER_FLAGS_INIT. For
any configuration run (including the first), the environment variable
will be ignored if the equivalent CMAKE_<TYPE>_LINKER_FLAGS_INIT vari-
able is defined.
MACOSX_DEPLOYMENT_TARGET
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Specify the minimum version of macOS on which the target binaries are
to be deployed.
The MACOSX_DEPLOYMENT_TARGET environment variable sets the default
value for the CMAKE_OSX_DEPLOYMENT_TARGET variable.
<PackageName>_ROOT
New in version 3.12.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Calls to find_package(<PackageName>) will search in prefixes specified
by the <PackageName>_ROOT environment variable, where <PackageName> is
the name given to the find_package() call and _ROOT is literal. For
example, find_package(Foo) will search prefixes specified in the
Foo_ROOT environment variable (if set). See policy CMP0074.
This variable may hold a single prefix or a list of prefixes separated
by : on UNIX or ; on Windows (the same as the PATH environment variable
convention on those platforms).
See also the <PackageName>_ROOT CMake variable.
VERBOSE
New in version 3.14.
Activates verbose output from CMake and your build tools of choice when
you start to actually build your project.
Note that any given value is ignored. It's just checked for existence.
See also Build Tool Mode and CMAKE_NO_VERBOSE environment variable
ENVIRONMENT VARIABLES FOR LANGUAGES
ASM<DIALECT>
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling a specific dialect of assembly lan-
guage files. ASM<DIALECT> can be ASM, ASM_NASM (Netwide Assembler),
ASM_MASM (Microsoft Assembler) or ASM-ATT (Assembler AT&T). Will only
be used by CMake on the first configuration to determine ASM<DIALECT>
compiler, after which the value for ASM<DIALECT> is stored in the cache
as CMAKE_ASM<DIALECT>_COMPILER. For subsequent configuration runs, the
environment variable will be ignored in favor of
CMAKE_ASM<DIALECT>_COMPILER.
NOTE:
Options that are required to make the compiler work correctly can be
included; they can not be changed.
$ export ASM="custom-compiler --arg1 --arg2"
ASM<DIALECT>FLAGS
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default compilation flags to be used when compiling a specific dialect
of an assembly language. ASM<DIALECT>FLAGS can be ASMFLAGS, ASM_NASM-
FLAGS, ASM_MASMFLAGS or ASM-ATTFLAGS. Will only be used by CMake on the
first configuration to determine ASM_<DIALECT> default compilation
flags, after which the value for ASM<DIALECT>FLAGS is stored in the
cache as CMAKE_ASM<DIALECT>_FLAGS <CMAKE_<LANG>_FLAGS>. For any con-
figuration run (including the first), the environment variable will be
ignored, if the CMAKE_ASM<DIALECT>_FLAGS <CMAKE_<LANG>_FLAGS> variable
is defined.
See also CMAKE_ASM<DIALECT>_FLAGS_INIT.
CC
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling C language files. Will only be used
by CMake on the first configuration to determine C compiler, after
which the value for CC is stored in the cache as CMAKE_C_COMPILER. For
any configuration run (including the first), the environment variable
will be ignored if the CMAKE_C_COMPILER variable is defined.
NOTE:
Options that are required to make the compiler work correctly can be
included; they can not be changed.
$ export CC="custom-compiler --arg1 --arg2"
CFLAGS
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default compilation flags to be used when compiling C files. Will only
be used by CMake on the first configuration to determine CC default
compilation flags, after which the value for CFLAGS is stored in the
cache as CMAKE_C_FLAGS. For any configuration run (including the
first), the environment variable will be ignored if the CMAKE_C_FLAGS
variable is defined.
See also CMAKE_C_FLAGS_INIT.
CSFLAGS
New in version 3.9.2.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default compilation flags to be used when compiling CSharp files. Will
only be used by CMake on the first configuration to determine CSharp
default compilation flags, after which the value for CSFLAGS is stored
in the cache as CMAKE_CSharp_FLAGS. For any configuration run (includ-
ing the first), the environment variable will be ignored if the
CMAKE_CSharp_FLAGS variable is defined.
See also CMAKE_CSharp_FLAGS_INIT.
CUDAARCHS
New in version 3.20.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Value used to initialize CMAKE_CUDA_ARCHITECTURES on the first configu-
ration if it's not already defined. Subsequent runs will use the value
stored in the cache.
This is a semicolon-separated list of architectures as described in
CUDA_ARCHITECTURES.
CUDACXX
New in version 3.8.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling CUDA language files. Will only be
used by CMake on the first configuration to determine CUDA compiler,
after which the value for CUDA is stored in the cache as
CMAKE_CUDA_COMPILER. For any configuration run (including the first),
the environment variable will be ignored if the CMAKE_CUDA_COMPILER
variable is defined.
NOTE:
Options that are required to make the compiler work correctly can be
included; they can not be changed.
$ export CUDACXX="custom-compiler --arg1 --arg2"
CUDAFLAGS
New in version 3.8.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default compilation flags to be used when compiling CUDA files. Will
only be used by CMake on the first configuration to determine CUDA
default compilation flags, after which the value for CUDAFLAGS is
stored in the cache as CMAKE_CUDA_FLAGS. For any configuration run
(including the first), the environment variable will be ignored if the
CMAKE_CUDA_FLAGS variable is defined.
See also CMAKE_CUDA_FLAGS_INIT.
CUDAHOSTCXX
New in version 3.8.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling host code when compiling CUDA lan-
guage files. Will only be used by CMake on the first configuration to
determine CUDA host compiler, after which the value for CUDAHOSTCXX is
stored in the cache as CMAKE_CUDA_HOST_COMPILER. For any configuration
run (including the first), the environment variable will be ignored if
the CMAKE_CUDA_HOST_COMPILER variable is defined.
This environment variable is primarily meant for use with projects that
enable CUDA as a first-class language.
NOTE:
Ignored when using Visual Studio Generators.
New in version 3.13: The FindCUDA module will use this variable to ini-
tialize its CUDA_HOST_COMPILER setting.
CXX
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling CXX language files. Will only be
used by CMake on the first configuration to determine CXX compiler,
after which the value for CXX is stored in the cache as CMAKE_CXX_COM-
PILER. For any configuration run (including the first), the environment
variable will be ignored if the CMAKE_CXX_COMPILER variable is defined.
NOTE:
Options that are required to make the compiler work correctly can be
included; they can not be changed.
$ export CXX="custom-compiler --arg1 --arg2"
CXXFLAGS
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default compilation flags to be used when compiling CXX (C++) files.
Will only be used by CMake on the first configuration to determine CXX
default compilation flags, after which the value for CXXFLAGS is stored
in the cache as CMAKE_CXX_FLAGS. For any configuration run ( including
the first), the environment variable will be ignored if the
CMAKE_CXX_FLAGS variable is defined.
See also CMAKE_CXX_FLAGS_INIT.
FC
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling Fortran language files. Will only be
used by CMake on the first configuration to determine Fortran compiler,
after which the value for Fortran is stored in the cache as CMAKE_For-
tran_COMPILER. For any configuration run (including the first), the
environment variable will be ignored if the CMAKE_Fortran_COMPILER
variable is defined.
NOTE:
Options that are required to make the compiler work correctly can be
included; they can not be changed.
$ export FC="custom-compiler --arg1 --arg2"
FFLAGS
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default compilation flags to be used when compiling Fortran files. Will
only be used by CMake on the first configuration to determine Fortran
default compilation flags, after which the value for FFLAGS is stored
in the cache as CMAKE_Fortran_FLAGS. For any configuration run (includ-
ing the first), the environment variable will be ignored if the
CMAKE_Fortran_FLAGS variable is defined.
See also CMAKE_Fortran_FLAGS_INIT.
HIPCXX
New in version 3.21.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling HIP language files. Will only be
used by CMake on the first configuration to determine HIP compiler,
after which the value for HIP is stored in the cache as CMAKE_HIP_COM-
PILER. For any configuration run (including the first), the environment
variable will be ignored if the CMAKE_HIP_COMPILER variable is defined.
HIPFLAGS
New in version 3.21.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default compilation flags to be used when compiling HIP files. Will
only be used by CMake on the first configuration to determine HIP
default compilation flags, after which the value for HIPFLAGS is stored
in the cache as CMAKE_HIP_FLAGS. For any configuration run (including
the first), the environment variable will be ignored if the
CMAKE_HIP_FLAGS variable is defined.
See also CMAKE_HIP_FLAGS_INIT.
ISPC
New in version 3.19.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling ISPC language files. Will only be
used by CMake on the first configuration to determine ISPC compiler,
after which the value for ISPC is stored in the cache as
CMAKE_ISPC_COMPILER. For any configuration run (including the first),
the environment variable will be ignored if the CMAKE_ISPC_COMPILER
variable is defined.
ISPCFLAGS
New in version 3.19.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default compilation flags to be used when compiling ISPC files. Will
only be used by CMake on the first configuration to determine ISPC
default compilation flags, after which the value for ISPCFLAGS is
stored in the cache as CMAKE_ISPC_FLAGS. For any configuration run
(including the first), the environment variable will be ignored if the
CMAKE_ISPC_FLAGS variable is defined.
See also CMAKE_ISPC_FLAGS_INIT.
OBJC
New in version 3.16.7.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling OBJC language files. Will only be
used by CMake on the first configuration to determine OBJC compiler,
after which the value for OBJC is stored in the cache as
CMAKE_OBJC_COMPILER. For any configuration run (including the first),
the environment variable will be ignored if the CMAKE_OBJC_COMPILER
variable is defined.
If OBJC is not defined, the CC environment variable will be checked
instead.
OBJCXX
New in version 3.16.7.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling OBJCXX language files. Will only be
used by CMake on the first configuration to determine OBJCXX compiler,
after which the value for OBJCXX is stored in the cache as
CMAKE_OBJCXX_COMPILER. For any configuration run (including the first),
the environment variable will be ignored if the CMAKE_OBJCXX_COMPILER
variable is defined.
If OBJCXX is not defined, the CXX environment variable will be checked
instead.
RC
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling resource files. Will only be used by
CMake on the first configuration to determine resource compiler, after
which the value for RC is stored in the cache as CMAKE_RC_COMPILER. For
any configuration run (including the first), the environment variable
will be ignored if the CMAKE_RC_COMPILER variable is defined.
NOTE:
Options that are required to make the compiler work correctly can be
included; they can not be changed.
$ export RC="custom-compiler --arg1 --arg2"
RCFLAGS
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Default compilation flags to be used when compiling resource files.
Will only be used by CMake on the first configuration to determine
resource default compilation flags, after which the value for RCFLAGS
is stored in the cache as CMAKE_RC_FLAGS. For any configuration run
(including the first), the environment variable will be ignored if the
CMAKE_RC_FLAGS variable is defined.
See also CMAKE_RC_FLAGS_INIT.
SWIFTC
New in version 3.15.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Preferred executable for compiling Swift language files. Will only be
used by CMake on the first configuration to determine Swift compiler,
after which the value for SWIFTC is stored in the cache as
CMAKE_Swift_COMPILER. For any configuration run (including the first),
the environment variable will be ignored if the CMAKE_Swift_COMPILER
variable is defined.
NOTE:
Options that are required to make the compiler work correctly can be
included; they can not be changed.
$ export SWIFTC="custom-compiler --arg1 --arg2"
ENVIRONMENT VARIABLES FOR CTEST
CTEST_INTERACTIVE_DEBUG_MODE
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Environment variable that will exist and be set to 1 when a test exe-
cuted by ctest(1) is run in interactive mode.
CTEST_OUTPUT_ON_FAILURE
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Boolean environment variable that controls if the output should be
logged for failed tests. Set the value to 1, True, or ON to enable out-
put on failure. See ctest(1) for more information on controlling out-
put of failed tests.
CTEST_PARALLEL_LEVEL
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Specify the number of tests for CTest to run in parallel. See ctest(1)
for more information on parallel test execution.
CTEST_PROGRESS_OUTPUT
New in version 3.13.
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Boolean environment variable that affects how ctest command output
reports overall progress. When set to 1, TRUE, ON or anything else
that evaluates to boolean true, progress is reported by repeatedly
updating the same line. This greatly reduces the overall verbosity,
but is only supported when output is sent directly to a terminal. If
the environment variable is not set or has a value that evaluates to
false, output is reported normally with each test having its own start
and end lines logged to the output.
The --progress option to ctest overrides this environment variable if
both are given.
CTEST_USE_LAUNCHERS_DEFAULT
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Initializes the CTEST_USE_LAUNCHERS variable if not already defined.
DASHBOARD_TEST_FROM_CTEST
This is a CMake Environment Variable. Its initial value is taken from
the calling process environment.
Environment variable that will exist when a test executed by ctest(1)
is run in non-interactive mode. The value will be equal to CMAKE_VER-
SION.
ENVIRONMENT VARIABLES FOR THE CMAKE CURSES INTERFACE
CCMAKE_COLORS
New in version 3.18.
Determines what colors are used by the CMake curses interface, when run
on a terminal that supports colors. The syntax follows the same con-
ventions as LS_COLORS; that is, a list of key/value pairs separated by
:.
Keys are a single letter corresponding to a CMake cache variable type:
o s: A STRING.
o p: A FILEPATH.
o c: A value which has an associated list of choices.
o y: A BOOL which has a true-like value (e.g. ON, YES).
o n: A BOOL which has a false-like value (e.g. OFF, NO).
Values are an integer number that specifies what color to use. 0 is
black (you probably don't want to use that). Others are determined by
your terminal's color support. Most (color) terminals will support at
least 8 or 16 colors. Some will support up to 256 colors. The colors
will likely match this chart, although the first 16 colors may match
the original CGA color palette. (Many modern terminal emulators also
allow their color palette, at least for the first 16 colors, to be con-
figured by the user.)
Note that fairly minimal checking is done for bad colors (although a
value higher than what curses believes your terminal supports will be
silently ignored) or bad syntax.
For example:
CCMAKE_COLORS='s=39:p=220:c=207:n=196:y=46'
COPYRIGHT
2000-2021 Kitware, Inc. and Contributors
ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
+---------------+-----------------------+
|ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+---------------+-----------------------+
|Availability | developer/build/cmake |
+---------------+-----------------------+
|Stability | Uncommitted |
+---------------+-----------------------+
NOTES
Source code for open source software components in Oracle Solaris can
be found at https://www.oracle.com/downloads/opensource/solaris-source-
code-downloads.html.
This software was built from source available at
https://github.com/oracle/solaris-userland. The original community
source was downloaded from
http://www.cmake.org/files/v3.21/cmake-3.21.0.tar.gz.
Further information about this software can be found on the open source
community website at http://www.cmake.org/.
3.21.0 Jun 27, 2022 CMAKE-ENV-VARIABLES(7)