Skip to content
Latchkey

CMake "No CMAKE_CXX_COMPILER could be found" in CI

At configure time CMake probes for a working C++ compiler and found none. On a minimal runner image, g++ or clang++ is simply not installed. Installing a compiler (or telling CMake which one to use) resolves it.

What this error means

CMake configure fails with "No CMAKE_CXX_COMPILER could be found." right after "The CXX compiler identification is unknown".

CMake
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path.

Common causes

No C++ compiler on the runner

A slim image ships without g++/clang++, so CMake finds nothing to compile with.

The compiler is installed but not on PATH

A toolchain in a custom location is not discoverable, so CMake cannot detect it automatically.

How to fix it

Install a C++ compiler

Provision g++ (or clang) before configuring.

Terminal
# Debian/Ubuntu
sudo apt-get update && sudo apt-get install -y g++
# or the full base toolchain
sudo apt-get install -y build-essential

Tell CMake which compiler to use

Set CXX or CMAKE_CXX_COMPILER when the compiler is in a non-standard path.

Terminal
cmake -B build -DCMAKE_CXX_COMPILER=g++-13

How to prevent it

  • Install build-essential (or clang) in the setup step for C/C++ jobs.
  • Use a runner image that ships the compiler when builds are frequent.
  • Pin the compiler with CXX so detection never guesses wrong.

Frequently asked questions

What causes ""No CMAKE_CXX_COMPILER could be found""?
A slim image ships without g++/clang++, so CMake finds nothing to compile with.
How do I fix "No CMAKE_CXX_COMPILER could be found"?
Provision g++ (or clang) before configuring.

Related guides

References

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