Hey! I’m running into an issue with CMake on my Windows machine (Visual Studio 2019 generator).
It seems this is specific to my system, but hope you have a clue on how to workaround. Non-cmake generated Visual Studio projects work fine. Before creating this issue, I was googling this error 2 days and didn’t succeed. Thanks for your attention!
My CMakeLists.txt
:
cmake_minimum_required(VERSION 3.22)
project(test)
Output:
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
CMake Error at CMakeLists.txt:2 (project):
Failed to run MSBuild command:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/MSBuild.exe
to get the value of VCTargetsPath:
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 26.08.2022 13:32:38.
Project "C:\projects\test\build\CMakeFiles\3.24.1\VCTargetsPath.vcxproj" on node 1 (default targets).
InitializeBuildStatus:
Touching "x64\Debug\VCTargetsPath.tlog\unsuccessfulbuild".
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6004: The specified task executable location "C:\WINDOWS\system32\cmd.exe" is invalid. [C:\projects\test\build\CMakeFiles\3.24.1\VCTargetsPath.vcxproj]
Done Building Project "C:\projects\test\build\CMakeFiles\3.24.1\VCTargetsPath.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\projects\test\build\CMakeFiles\3.24.1\VCTargetsPath.vcxproj" (default target) (1) ->
(PostBuildEvent target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6004: The specified task executable location "C:\WINDOWS\system32\cmd.exe" is invalid. [C:\projects\test\build\CMakeFiles\3.24.1\VCTargetsPath.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.41
Exit code: 1
-- Configuring incomplete, errors occurred!
See also "C:/projects/test/build/CMakeFiles/CMakeOutput.log".