CMake"无法运行MSBUILD.exe"命令错误

时间:2017-08-26 08:43:26

标签: visual-studio configuration cmake opencv3.0

当我想为opencv 3.3.0创建visual studio 15(2017)make文件时,它会给我这个错误消息:error in configuration process, project files maybe invalid和这些:

CMake Deprecation Warning at CMakeLists.txt:81 (cmake_policy):
  The OLD behavior for policy CMP0020 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:85 (cmake_policy):
  The OLD behavior for policy CMP0022 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:94 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Error at CMakeLists.txt:127 (project):
  Failed to run MSBuild command:

    MSBuild.exe

  to get the value of VCTargetsPath:

我使用的是Windows 10.问题是什么?如何解决?

3 个答案:

答案 0 :(得分:6)

在CMake-gui:选择了源代码&二进制文件夹并单击“配置”它将询问您使用哪个版本的编译器。确保选择正确的

例如,如果安装了“Visual Studio 2015”并选择“Visual Studio 2017”,则会遇到“无法运行MSBuild命令:”错误。

如果确实选择了错误的,请删除binaries-folder或只使用其他二进制文件夹 - 然后单击configure并选择正确的编译器。

答案 1 :(得分:3)

尝试安装 Windows SDK Windows 10 SDK)并使用管理员权限运行CMake。 如果这样做没有用,请使用完整的警告和错误消息编辑您的问题,就像当前的一样,您已跳过最重要的部分。

答案 2 :(得分:0)

只要cmake找不到Visual Studio组件,那是因为cmake使用的生成选项指定了您尚未安装的版本。因此,更改cmake选项或使用必需的组件(通常是Visual C ++组件和Windows SDK组件)安装所需的Visual Studio版本(14.0 = 2015、15.0 = 2017、16.0 = 2019)。