Skip to content
Latchkey

CMake empty or wrong CMAKE_BUILD_TYPE in CI

With single-config generators (Unix Makefiles, Ninja), CMAKE_BUILD_TYPE selects the optimization and flags. When it is empty or misspelled, CMake builds with no optimization or ignores your intended profile, producing slow or wrong binaries in CI.

What this error means

The build succeeds but binaries are unoptimized, or a build-type-specific step behaves oddly, because CMAKE_BUILD_TYPE was empty or set to a value CMake does not recognize such as "release" instead of "Release".

cmake
-- Build type not specified, using no optimization flags
-- CMAKE_BUILD_TYPE=''

Common causes

CMAKE_BUILD_TYPE was never passed

Single-config generators default to an empty build type, so no -O flags are applied and the binary is unoptimized.

The value is misspelled or wrong case

CMake compares against Debug, Release, RelWithDebInfo, MinSizeRel; "release" or "prod" does not match a known configuration.

How to fix it

Pass an exact build type

Set CMAKE_BUILD_TYPE to a recognized value at configure time for single-config generators.

Terminal
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

Select config at build time for multi-config

With multi-config generators, pass --config at build time instead of CMAKE_BUILD_TYPE.

Terminal
cmake --build build --config Release

How to prevent it

  • Always set CMAKE_BUILD_TYPE explicitly for Makefiles/Ninja.
  • Use the exact capitalization: Debug, Release, RelWithDebInfo, MinSizeRel.
  • Encode the build type in a CMake preset so CI cannot forget it.

Frequently asked questions

What causes "empty CMAKE_BUILD_TYPE"?
Single-config generators default to an empty build type, so no -O flags are applied and the binary is unoptimized.
How do I fix empty CMAKE_BUILD_TYPE?
Set CMAKE_BUILD_TYPE to a recognized value at configure time for single-config generators.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card