CMake 为 UWP 生成时无法获取 VCTargetsPath 的值

jha*_*sse 5 c++ cmake windows-store-apps uwp

我正在尝试使用 CMake 构建通用 Windows 应用程序,但出现以下构建错误(已安装最新的 Visual Studio 2019 和 Windows 10 SDK):

\n\n
\xe2\x80\xba cmake -B. -H<my source dir> -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0\n-- Building for: Visual Studio 16 2019\n-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.\nCMake Error at CMakeLists.txt:3 (project):\n  Failed to run MSBuild command:\n\n    C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe\n\n  to get the value of VCTargetsPath:\n\n    Microsoft (R) Build Engine version 16.5.1+4616136f8 for .NET Framework\n    Copyright (C) Microsoft Corporation. All rights reserved.\n\n    Build started 5/16/2020 9:52:00 PM.\n    Project "C:\\test\\CMakeFiles\\3.17.2\\VCTargetsPath.vcxproj" on node 1 (default targets).\n    C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\Microsoft.Common.CurrentVersion.targets(777,5): error : The OutputPath property is not set for project \'VCTargetsPath.vcxproj\'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration=\'Debug\'  Platform=\'x64\'.  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn\'t exist for this project. [C:\\test\\CMakeFiles\\3.17.2\\VCTargetsPath.vcxproj]\n    Done Building Project "C:\\test\\CMakeFiles\\3.17.2\\VCTargetsPath.vcxproj" (default targets) -- FAILED.\n\n    Build FAILED.\n\n    "C:\\test\\CMakeFiles\\3.17.2\\VCTargetsPath.vcxproj" (default target) (1) ->\n    (_CheckForInvalidConfigurationAndPlatform target) ->\n      C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\Microsoft.Common.CurrentVersion.targets(777,5): error : The OutputPath property is not set for project \'VCTargetsPath.vcxproj\'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration=\'Debug\'  Platform=\'x64\'.  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn\'t exist for this project. [C:\\test\\CMakeFiles\\3.17.2\\VCTargetsPath.vcxproj]\n\n        0 Warning(s)\n        1 Error(s)\n\n    Time Elapsed 00:00:00.07\n\n\n  Exit code: 1\n\n\n\n-- Configuring incomplete, errors occurred!\n
Run Code Online (Sandbox Code Playgroud)\n\n

这意味着什么?我还尝试指定确切的 Windows SDK 版本CMAKE_SYSTEM_VERSION,但没有成功。

\n

ars*_*ver 3

我解决了这个问题。我做了很多事情,因此我无法判断哪一项真正解决了问题。但请尝试以下操作。

VisualStudio Installer应用程序中,单击Modify并安装C++ Universal Windows Platform support for v142 build tools (ARM64)单个组件。