Vscode-cmake-tools: VSCode cannot find CMake generator

Created on 7 Nov 2019  路  12Comments  路  Source: microsoft/vscode-cmake-tools

Brief Issue Summary

I update VSCode 1.40.0. And, CMake cannot find CMake generator.
In previous VSCode version, I can use CMake/Build.

CMake Tools Log

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.

Platform and Versions

  • Operating System: Windows 10
  • CMake Version: 3.14.0
  • VSCode Version: 1.40.0
  • CMake Tools Extension Version: 1.2.1
  • Compiler/Toolchain: mingw-w64 gcc, g++
configure IMPORTANT fixed (release pending)

Most helpful comment

I had MSYS2-MinGW installed and the way I solved it:

  1. I assume you have the below MSYS2 packages installed with pacman -S:

    • mingw64/mingw-w64-x86_64-gcc

    • mingw64/mingw-w64-x86_64-make

    • mingw64/mingw-w64-x86_64-cmake

  2. You need to open the settings.json by Ctrl + Shift + P and serach-select Preference: Open settings (JSON)
  3. and then add the lines below:

~json
"cmake.cmakePath": "C:\msys64\mingw64\bin\cmake.exe",
"cmake.mingwSearchDirs": [
"C:\msys64\mingw64\bin"
],
"cmake.generator": "MinGW Makefiles"
~

  1. and then open the CMake: Edit User-Local CMake Kits which opens the cmake-tools-kits.json file where you need to have:

~json
{
"name": "Mingw64 GCC 9.3.0",
"compilers": {
"C": "C:\msys64\mingw64\bin\gcc.exe",
"CXX": "C:\msys64\mingw64\bin\g++.exe"
},
"preferredGenerator": {
"name": "MinGW Makefiles",
"platform": "x64"
},
"environmentVariables": {
"PATH": "C:/msys64/mingw64/bin/"
}
}
~

All 12 comments

The same problem with "settings.json" and "cmake-kits.json...

I had the same issue after upgrading VSCode to version 1.40.0.

Previously I had set my PATH environment via settings.json cmake.environment. After the update it seems CMake-Tools were unable to find my toolset (generator: Unix Makefiles).

I fixed this issue with setting environmentVariables in cmake-kits.json for my toolchain.

Can you share any of your settings? I'm not able to reproduce this problem.

settings.json

{
    "cmake.mingwSearchDirs": [
        "C:\\mingw-w64\\mingw64\\bin"
    ],
    "cmake.generator": "MinGW Makefiles"
}

cmake-tools-kits.json

  ...
  {
    "name": "GCC 7.2.0",
    "compilers": {
      "C": "C:\\mingw-w64\\mingw64\\bin\\gcc.exe",
      "CXX": "C:\\mingw-w64\\mingw64\\bin\\g++.exe"
    },
    "preferredGenerator": {
      "name": "MinGW Makefiles"
    },
    "environmentVariables": {
      "CMT_MINGW_PATH": "C:\\mingw-w64\\mingw64\\bin"
    }
  },
  ...

1.2.2 was released today. Please give that a try and let us know if you continue to have issues.

I solved! Thank you.

VSCode: v1.40.1
CMake Tolls: v1.2.2

I'm running 1.41.1 and I still have problems. Maybe this is specifically due to using a toolchain file, but I still get the same error:

[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.

@renebarto, can you open a new issue with details about your project and configuration?

Thank you!

I had MSYS2-MinGW installed and the way I solved it:

  1. I assume you have the below MSYS2 packages installed with pacman -S:

    • mingw64/mingw-w64-x86_64-gcc

    • mingw64/mingw-w64-x86_64-make

    • mingw64/mingw-w64-x86_64-cmake

  2. You need to open the settings.json by Ctrl + Shift + P and serach-select Preference: Open settings (JSON)
  3. and then add the lines below:

~json
"cmake.cmakePath": "C:\msys64\mingw64\bin\cmake.exe",
"cmake.mingwSearchDirs": [
"C:\msys64\mingw64\bin"
],
"cmake.generator": "MinGW Makefiles"
~

  1. and then open the CMake: Edit User-Local CMake Kits which opens the cmake-tools-kits.json file where you need to have:

~json
{
"name": "Mingw64 GCC 9.3.0",
"compilers": {
"C": "C:\msys64\mingw64\bin\gcc.exe",
"CXX": "C:\msys64\mingw64\bin\g++.exe"
},
"preferredGenerator": {
"name": "MinGW Makefiles",
"platform": "x64"
},
"environmentVariables": {
"PATH": "C:/msys64/mingw64/bin/"
}
}
~

@Foadsf, you may not want to nuke your %PATH% by overwriting it with just the MinGW path. We created "CMT_MINGW_PATH" which will be added to the %PATH% when the environment is created.

@bobbrow so is it ok if I just change

"PATH": "C:/msys64/mingw64/bin/"

to

"CMT_MINGW_PATH": "C:/msys64/mingw64/bin/"

Yes, that should work.

CMT_MINGW_PATH and its behavior should be documented somewhere (probably here: https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/kits.md#general-options under environmentVariables).
I'm not sure if I'm misusing this to add the path to my ninja generator. The name does not sound like it should be used as a general purpose "add this path to the path variable"-function.

It works using CMT_MINGW_PATH but I've opted to use the following instead for now:

"cmakeSettings": {
   "CMAKE_MAKE_PROGRAM": "${workspaceFolder}/../Tools/ninja/ninja.exe"
}
Was this page helpful?
0 / 5 - 0 ratings