【发布时间】:2021-04-13 12:17:29
【问题描述】:
我为 VS2017 生成了 CMake 项目。当我尝试使用 cmake.exe --build "build\release_2017" --target pemd5 从命令行构建 Release 配置时,它失败并出现错误:
C:\Program Files (x86)\Microsoft Visual Studio\2017\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)。
我在源目录中的 CMakeLists.txt 脚本都没有条件 CMAKE_CONFIGURATION_TYPES 部分。 Debug 和 Release 都是 VS2017 使用以下命令生成的:
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\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 STUDIO\2017\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": []
},
....
有什么建议吗???
提前致谢。
【问题讨论】:
标签: visual-studio-2010 cmake msbuild visual-studio-2017