【发布时间】: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