【问题标题】:Why I cannot see CMake version from the terminal inside Visual Studio Code?为什么我无法从 Visual Studio Code 中的终端看到 CMake 版本?
【发布时间】:2020-09-16 08:41:51
【问题描述】:

我在 Windows 上安装了 CMake,并添加了系统变量的路径 (C:\Program Files\CMake\bin)

我可以在命令提示符下看到它:

D:\>cmake --version
cmake version 3.18.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).

但是当我尝试从 Visual Studio Code 的终端执行相同操作时,出现错误:

PS D:\Cmake\Mastering-CMake> cmake --version
cmake : The term 'cmake' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path 
is correct and try again.
At line:1 char:1
+ cmake --version
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (cmake:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

CMake 扩展也报错:

The "cmake" command is not found in PATH.  Install it or use `cmake.cmakePath` in the workspace settings to define the CMake executable binary.

但我已经将 CMake 添加到路径中。我还应该做什么?谢谢!

【问题讨论】:

  • (在 VS Code 终端中)PS ...> where.exe cmake 应该输出 CMake 的路径。
  • PS ...> $env:Path -split ';' | Select-String '\bcmake\b' 也应该输出到 CMake 的路径。
  • 如果这些命令中的任何一个失败,那么您需要检查环境,或 VS Code 设置,或者可能重新启动操作系统。
  • 您在启动 Visual Studio Code 后是否将 CMake 添加到路径中?您可能需要重新启动代码。
  • 其实我已经在CMake configuration扩展中调整了CMake路径(在设置中)。此外,我已将 CMake 路径添加到系统 PATH 中。

标签: windows visual-studio-code cmake path


【解决方案1】:

重新启动 Visual Studio Code 使其更新 PATH。 新终端现在可以找到cmake

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-12
    • 2020-01-12
    • 2021-12-30
    • 2018-08-05
    • 2023-01-13
    • 2021-08-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多