Ben Comer
Ben Comer

Reputation: 11

Running into "Unable to determine what CMake generator to use..."

I'm trying to set up CMake on Visual Studio code on my computer. I haven't coded outside of work for about a year, and I'm running into problems just setting it up. I've installed the latest version of VS Code, G++ (compiler), mingw, and CMake, including any needed extensions, but I'm still running into this upon using the VSCode "Build" button via CMake Tools:

[main] Building folder: cmakeQuickStart [proc] Executing command: C:\msys64\mingw64\bin\gcc.exe -v [proc] The command: ninja --version failed with error: Error: spawn ninja ENOENT [proc] The command: ninja-build --version failed with error: Error: spawn ninja-build ENOENT [proc] The command: make --version failed with error: Error: spawn make ENOENT [main] Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable. Error: No usable generator found. [rollbar] Unhandled exception: Unhandled Promise rejection: build Error: Build failed: Unable to configure the project {}

This is on a HelloWorld project, and my others. I don't know where to go, I've tried dang near everything. Help!

I've tried reinstalling all my components as mentioned above, and starting a new project with the recommended Quick Start on CMake Tools. This error still shows. I've added mingw to my environment variables; I keep seeing that I should add cmake to it as wel, but I'm not sure how.

Upvotes: 1

Views: 5023

Answers (1)

Lemonina
Lemonina

Reputation: 907

  1. "No usable generator found" indicates that CMake can't determine the generator to use for building the project -- specify the generator -- add this to settings.json (replace "MinGW Makefiles" with the generator that you are using -- "g++.exe" + "gcc.exe" with path to your compilers)
"CMakeTools.generator": "MinGW Makefiles",
"CMakeTools.configureSettings": {
    "CMAKE_CXX_COMPILER": "g++.exe",
    "CMAKE_C_COMPILER": "gcc.exe"
}
  1. "Error: spawn ninja ENOENT" show that CMake Tools can't find the Ninja build system -- install Ninja (add path to Ninja executable to system's PATH environment variable)
mingw-get install ninja
  1. how to add CMake to environment variables
  • start menu > environment variables > Edit the system environment variables > Environment Variables
  • under System variables -- Path > Edit > New > add path to the CMake executable directory > OK on all windows to save changes

once you fix all these issues, try building your project again.

Upvotes: -1

Related Questions