Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode cannot find CMake generator #880

Closed
tnakaicode opened this issue Nov 7, 2019 · 12 comments
Closed

VSCode cannot find CMake generator #880

tnakaicode opened this issue Nov 7, 2019 · 12 comments
Assignees
Labels
Feature: configure fixed (release pending) fixed in pre-release and is pending official release IMPORTANT
Milestone

Comments

@tnakaicode
Copy link

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++
@mischelebuha
Copy link

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

@chilippso
Copy link

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.

@bobbrow
Copy link
Member

bobbrow commented Nov 12, 2019

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"
    }
  },
  ...

@bobbrow bobbrow added the fixed (release pending) fixed in pre-release and is pending official release label Nov 12, 2019
@bobbrow
Copy link
Member

bobbrow commented Nov 13, 2019

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

@tnakaicode
Copy link
Author

I solved! Thank you.

VSCode: v1.40.1
CMake Tolls: v1.2.2

@renebarto
Copy link

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.

@bobbrow
Copy link
Member

bobbrow commented Jan 22, 2020

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

Thank you!

@Foadsf
Copy link

Foadsf commented Mar 14, 2020

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
  1. You need to open the settings.json by Ctrl + Shift + P and serach-select Preference: Open settings (JSON)
  2. and then add the lines below:
    "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:
  {
    "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/"
    }
  }

@bobbrow
Copy link
Member

bobbrow commented Mar 16, 2020

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

@Foadsf
Copy link

Foadsf commented Mar 16, 2020

@bobbrow so is it ok if I just change

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

to

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

@bobbrow
Copy link
Member

bobbrow commented Mar 16, 2020

Yes, that should work.

@Wastus
Copy link

Wastus commented Feb 9, 2021

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"
}

@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature: configure fixed (release pending) fixed in pre-release and is pending official release IMPORTANT
Projects
None yet
Development

No branches or pull requests

8 participants