C++ 'cmake' 未被识别为内部或外部命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19176029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 22:34:07  来源:igfitidea点击:

'cmake' is not recognised as an internal or external command

c++visual-studiocmake

提问by Ryan White

I'm trying to run cmake in Visual Studio 10, for esys-particle-win.

我正在尝试在 Visual Studio 10 中为 esys-particle-win 运行 cmake。

My path to cmake:C:\Program Files (x86)\CMake 2.8\bin\cmake.exe

我的 cmake 之路:C:\Program Files (x86)\CMake 2.8\bin\cmake.exe

My path to esys-particle-win:C:\esys-particle-win\trunk\buildvs2010\mkvs10.bat

我的 esys-particle-win 之路:C:\esys-particle-win\trunk\buildvs2010\mkvs10.bat

The commands I'm typing in the administrator command prompt of Visual Studio 2010 are:

我在 Visual Studio 2010 的管理员命令提示符中键入的命令是:

cd c:\esys-particle-win\trunk\buildvs2010
mkvs10.bat

and I'm getting this error:

我收到此错误:

'cmake' is not recognized as an internal or external command

contents of mkvs10.bat:

内容 mkvs10.bat

cmake .. -G "Visual Studio 10" -G "NMake Makefiles"

could anyone tell me where I am wrong?. I don't know computer programming. I followed the instructions mentioned in section 2.3.1 of this site: `

谁能告诉我我错在哪里?我不懂计算机编程。我按照本网站第 2.3.1 节中提到的说明进行操作:`

https://launchpadlibrarian.net/139659869/esys-particle-win-%28v2.1%29-build-instructions.pdf

https://launchpadlibrarian.net/139659869/esys-particle-win-%28v2.1%29-build-instructions.pdf

` Any help would be greatly appreciated, Thank you.

` 任何帮助将不胜感激,谢谢。

回答by doctorlove

The error message means it cannot find cmake.
You can add its location to your path from the prompt like this:

错误消息意味着它找不到 cmake。
您可以从提示中将其位置添加到您的路径中,如下所示:

set PATH="C:\Program Files (x86)\CMake 2.8\bin\";%PATH%

回答by Dave Voyles

As @doctorlovementioned above, the error message means it cannont find Cmake.

正如@doctorlove上面提到的,错误信息意味着它无法找到 Cmake。

Note that quotes aren't needed in PATH environmental variables on Windows. So the above example on Windows would look like:

请注意,Windows 上的 PATH 环境变量中不需要引号。因此,Windows 上的上述示例如下所示:

set PATH=C:\Program Files (x86)\CMake 2.8\bin\;%PATH% 

I had the same issue, and resolved it in this post.

我有同样的问题,并在这篇文章中解决了它。

回答by Pysis

I'm trying to build a project with my recently downloaded Visual Studio Community 2017, but had no CMake on my path.

我正在尝试使用我最近下载的 Visual Studio Community 2017 构建一个项目,但我的路径上没有 CMake。

It did not help, even after I had gained VCVars: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64

它没有帮助,即使在我获得了 VCVars 之后: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64

Instead of separately installing a copy that might work with these answers, although I'm not sure it would have the generators I need(?), I found one in the installation directory, which had a different path than what was in the guide I was using.

我没有单独安装一个可能适用于这些答案的副本,虽然我不确定它是否有我需要的生成器(?),但我在安装目录中找到了一个,它的路径与我在指南中的路径不同正在使用。

Here is my invocation line: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -G "Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE% ..

这是我的调用行: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -G "Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE% ..

回答by orion elenzil

note that if you installed cmake via chocolatey, you may have neglected to add the argument --installargs 'ADD_CMAKE_TO_PATH=System'. If you've already choco-installed cmake without that argument, re-installing via --force won't respect the new argument: you'll need to uninstall and then install. specifically choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'

请注意,如果您通过 Chocolatey 安装了 cmake,则您可能忽略了添加参数--installargs 'ADD_CMAKE_TO_PATH=System'. 如果您已经在没有该参数的情况下安装了 choco,则通过 --force 重新安装将不会尊重新参数:您需要卸载然后安装。具体来说choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'