Home

CMAKEBUILDTYPE

CMAKE_BUILD_TYPE is a CMake cache variable used by single-configuration generators to select a build configuration during the configure step. It affects which per-configuration compiler and linker flags are applied, by choosing among configuration-specific variables such as CMAKE_C_FLAGS_DEBUG, CMAKE_C_FLAGS_RELEASE, CMAKE_CXX_FLAGS_DEBUG, and similar for other languages. The typical, standard values are Debug, Release, RelWithDebInfo, and MinSizeRel, though projects may define additional or custom types.

Usage and impact: When configuring a project, you usually pass -DCMAKE_BUILD_TYPE=<type> to CMake, for example cmake

Generators and scope: CMAKE_BUILD_TYPE does not apply to multi-configuration generators such as Visual Studio or Xcode,

Notes: If CMAKE_BUILD_TYPE is not set for a single-configuration generator, no configuration-specific flags are automatically selected

-DCMAKE_BUILD_TYPE=Release
..
This
sets
up
the
appropriate
flags
and
settings
for
the
chosen
configuration
for
single-configuration
generators
like
Unix
Makefiles
or
Ninja.
The
build
then
uses
those
flags
when
compiling
and
linking.
where
the
active
configuration
is
selected
at
build
time
inside
the
IDE
or
with
a
--config
option
to
cmake
--build.
For
these
generators,
CMAKE_CONFIGURATION_TYPES
defines
the
available
configurations,
and
the
actual
build
configuration
is
chosen
independently
of
CMAKE_BUILD_TYPE.
unless
the
project
provides
defaults.
In
practice,
developers
often
configure
separate
build
trees
for
different
configurations
(e.g.,
Debug
and
Release)
or
rely
on
multi-configuration
generators
when
building
across
configurations
in
one
environment.