CMake "CMAKE_CXX_COMPILER not set" in CI
CMake could not determine a C++ compiler when the project enabled the CXX language. The compiler is not installed, not on PATH, or a toolchain file did not set it.
What this error means
Configure aborts complaining CMAKE_CXX_COMPILER is not set after EnableLanguage, usually on a minimal image lacking g++/clang++.
cmake
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_CXX_COMPILER could be found.
CMAKE_CXX_COMPILER not set, after EnableLanguageCommon causes
How to fix it
Install a C++ compiler
- Install build-essential or g++/clang++ before configuring.
- Or point CMake at a specific compiler with -DCMAKE_CXX_COMPILER.
cmake
apt-get install -y build-essential
cmake -S . -B build -DCMAKE_CXX_COMPILER=g++How to prevent it
- Bake a C++ toolchain into the runner image and verify g++/clang++ is on PATH before running CMake.
Related guides
CMake "No CMAKE_C_COMPILER could be found" in CIFix CMake "No CMAKE_C_COMPILER could be found" in CI - no C compiler is installed or on PATH for the project…
CMake "The C++ compiler ... is not able to compile a simple test program" in CIFix CMake "The C++ compiler is not able to compile a simple test program" (ABI detection) in CI - the toolcha…