I update VSCode 1.40.0. And, CMake cannot find CMake generator.
In previous VSCode version, I can use CMake/Build.
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.
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:
pacman -S:mingw64/mingw-w64-x86_64-gccmingw64/mingw-w64-x86_64-makemingw64/mingw-w64-x86_64-cmakesettings.json by Ctrl + Shift + P and serach-select Preference: Open settings (JSON)~json
"cmake.cmakePath": "C:\msys64\mingw64\bin\cmake.exe",
"cmake.mingwSearchDirs": [
"C:\msys64\mingw64\bin"
],
"cmake.generator": "MinGW Makefiles"
~
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"
}
Most helpful comment
I had MSYS2-MinGW installed and the way I solved it:
pacman -S:mingw64/mingw-w64-x86_64-gccmingw64/mingw-w64-x86_64-makemingw64/mingw-w64-x86_64-cmakesettings.jsonby Ctrl + Shift + P and serach-selectPreference: Open settings (JSON)~json"cmake.cmakePath": "C:\msys64\mingw64\bin\cmake.exe",
"cmake.mingwSearchDirs": [
"C:\msys64\mingw64\bin"
],
"cmake.generator": "MinGW Makefiles"
~
CMake: Edit User-Local CMake Kitswhich opens thecmake-tools-kits.jsonfile 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/"
}
}
~