microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 455 forks source link

Ninja not found #4089

Closed Lioncky closed 1 month ago

Lioncky commented 2 months ago

Brief Issue Summary

VSCode cmake/generate unable to find a build program corresponding to "Ninja" https://code.visualstudio.com/docs/terminal/profiles

It look like vscode has found cmake.exe by my self-define vs2022dev command prompt, but I have to add this

    "cmake.configureSettings": {
        "CMAKE_MAKE_PROGRAM": "C:/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe"
    },

into setting.json otherwise it can't find the ninja, maybe a bug?

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.93.1",
  "cmtVersion": "1.19.52",
  "configurations": [
    {
      "folder": "e:\\@KsaProj\\android\\AndCmd",
      "cmakeVersion": "3.29.5",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.

Additional Information

No response

Amy-Li03 commented 2 months ago

Hi @Lioncky, thank you for opening this report. Unfortunately we cannot repro this issue on a simple app, there is no error: CMake was unable to find a build program corresponding to "Ninja" even if "CMAKE_MAKE_PROGRAM" is not set in setting.json.

If you could provide some more information about this issue, that would be great. For example, repro steps to reproduce this, or a small example of a script you're using.

Amy-Li03 commented 2 months ago

From Garrett Campbell's response to a similar issue in https://github.com/microsoft/vscode-cmake-tools/issues/3443#issuecomment-2341166427:

Please ensure that you're making use of cmake.generator or cmake.preferredGenerator settings. In the most recent extension release it is expected that if you're using the unspecified kit for example, no generator is used unless it's found on the system, so you should be sure to define the cmake.generator setting. Thanks!

gcampbell-msft commented 1 month ago

I can confirm what @Amy-Li03 said above, closing this issue. THanks!