CMake "failed to run MSBUILD.exe" command error

Hasani picture Hasani · Aug 26, 2017 · Viewed 14.2k times · Source

When I want to create visual studio 15(2017) make files for opencv 3.3.0, it gives me this error message: error in configuration process, project files maybe invalid and these:

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:

I use windows 10. What is the problem and how can I fix it?

Answer

kalmiya picture kalmiya · Oct 2, 2017

In CMake-gui: After you selected the source & binary folder and click "configure" it will ask you which version of the compiler to use. Make sure that you select the correct one

For example, if you have "Visual Studio 2015" installed and you select "Visual Studio 2017", you will run into the "Failed to run MSBuild command:" error.

If you did select the wrong one, either delete the binaries-folder or simply use another binaries-folder - and then click configure and select the correct compiler.