CMake 编译cppcheck (Failed to run MSBuild command:)

Problem Description:

Recently, I used the cross-compiler CMake to compile cppcheck on windows, and found some puzzling problems. The bug and log information is as follows:

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

    MSBuild.exe

  to get the value of VCTargetsPath:
Configuring incomplete, errors occurred!

The log file shows:

The system is: Windows - 10.0.14393 - AMD64

Cause Analysis:

Many people say that this is because the version of the windos sdk is wrong, and it needs to be replaced with 8.1. Fortunately, I didn't change it.

Some people say that this is because you are using the VS compiler and you did not choose the correct compilation method when using CMake. This is a bit of a touch. In fact, it is due to the incorrect installation of the SDK and some toolkits downloaded in VS or not at all. installation.

Some people say that this is because CMake can't find the environment variables of MSBuild, but if you try it, you will find that even if you add the environment variables of MSBuild, you can't compile successfully.

solution:

Open Visual Studio Installerfor repair, my VS is 2017,
check whether the following tools are installed

Insert picture description here
And VS extension development
Insert picture description here

Then check the single component.
By the way, take a look at the SDK version. It doesn’t need 8.1. In fact, it
Insert picture description here
mainly depends on the CMake of the single component and the Visual tool of Linux, and the Visual C++ tool of CMake.
Insert picture description here
Insert picture description here
Repair it after installation, and compile again.
At this time, the above error will not be reported.
Insert picture description here

Do not redistribute without permission!

Guess you like

Origin blog.csdn.net/qq_42956179/article/details/114869735