CMake 为 VS2017 生成的项目需要安装 VS2010

CMake generated project for VS2017 requires VS2010 to be installed

我已经为 VS2017 生成了 CMake 项目。当我尝试使用 cmake.exe --build "build\release_2017" --target pemd5 从命令行构建 Release 配置时,它失败并出现错误:

C:\Program Files (x86)\Microsoft Visual Studio17\Professional\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(65,5): error MSB8020: The
 build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio
 2010 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, a
nd then selecting "Retarget solution". [D:\dev\syscore\build\release_2017\comlib\comlib.vcxproj]

相同的命令对于 Debug 配置完美无缺。更奇怪的是,如果我使用 VS2017 IDE 加载生成的解决方案,它会正确构建。 我还尝试使用 msbuild.exe build\release_2017\SysCore.sln 使用 MSBuild.exe 构建 .sln 文件。虽然结果稍微好一些,但我仍然遇到类似的错误:

Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 1/7/2021 10:07:46 AM.
Project "D:\dev\syscore\build\release_2017\SysCore.sln" on node 1 (default targets).
D:\dev\syscore\build\release_2017\SysCore.sln.metaproj : error MSB4126: The specified solution configuration "Release|x86" is invalid. Please spec
ify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platfo
rm="Any CPU") or leave those properties blank to use the default solution configuration. [D:\dev\syscore\build\release_2017\SysCore.sln]
Done Building Project "D:\dev\syscore\build\release_2017\SysCore.sln" (default targets) -- FAILED.


Build FAILED.

"D:\dev\syscore\build\release_2017\SysCore.sln" (default target) (1) ->
(ValidateSolutionConfiguration target) ->
  D:\dev\syscore\build\release_2017\SysCore.sln.metaproj : error MSB4126: The specified solution configuration "Release|x86" is invalid. Please sp
ecify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Plat
form="Any CPU") or leave those properties blank to use the default solution configuration. [D:\dev\syscore\build\release_2017\SysCore.sln]

    0 Warning(s)
    1 Error(s)

仅当我还指定了平台时,构建才会成功 (msbuild.exe build\release_2017\SysCore.sln -p:Platform=Win32)。

我在源目录中的

None 个 CMakeLists.txt 脚本具有条件 CMAKE_CONFIGURATION_TYPES 部分。 DebugRelease 都是由 VS2017 使用命令生成的:

C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO17\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe  -G "Visual Studio 15 2017" -DCMAKE_INSTALL_PREFIX:PATH="D:\dev\syscore\install\release_2017"  -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/HostX86/x86/cl.exe"  -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/HostX86/x86/cl.exe"  -DCMAKE_CONFIGURATION_TYPES="Release" "D:\dev\syscore"

C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO17\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe  -G "Visual Studio 15 2017" -DCMAKE_INSTALL_PREFIX:PATH="D:\dev\syscore\install\debug_2017"  -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/HostX86/x86/cl.exe"  -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/HostX86/x86/cl.exe"  -DCMAKE_CONFIGURATION_TYPES="Debug" "D:\dev\syscore"
1> Working directory: D:\dev\syscore\build\debug_2017

我的 CMakeSettings.json 看起来像:

{
    "configurations": [
        {
            "name": "debug_2017",
            "generator": "Visual Studio 15 2017",
            "configurationType": "Debug",
            "inheritEnvironments": [ "msvc_x86" ],
            "buildRoot": "${workspaceRoot}\build\${name}",
            "installRoot": "${workspaceRoot}\install\${name}",
            "cmakeCommandArgs": "",
            "buildCommandArgs": "-v:n -m:8",
            "ctestCommandArgs": "",
            "variables": []
        },
      {
        "name": "release_2017",
        "generator": "Visual Studio 15 2017",
        "configurationType": "Release",
        "inheritEnvironments": [ "msvc_x86" ],
        "buildRoot": "${workspaceRoot}\build\${name}",
        "installRoot": "${workspaceRoot}\install\${name}",
        "cmakeCommandArgs": "",
        "buildCommandArgs": "-v:d -m:8",
        "ctestCommandArgs": "",
        "variables": []
      },
....

有什么建议吗???

提前致谢。

这看起来像是 CMake 中的错误。到目前为止我发现的唯一解决方法是在 cmake.exe 命令行上为 MSBuild.exe 添加显式配置和平台(例如 cmake.exe --build ..... -- -p:Configuration=Debug -p:Platform=Win32