You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

使用Visual Studio 2013生成器构建Windows二进制文件时无法定位Microsoft.Cpp.Default.props的问题求助

使用Visual Studio 2013生成器构建Windows二进制文件时无法定位Microsoft.Cpp.Default.props的问题求助

我目前正处于学习用CMake在Windows上开发的入门阶段,如果问题比较基础还请见谅!我搜过类似问题,但都没能解决我的问题。

我拿到了一个需要在Windows上构建的Demo项目,它的CMakeLists.txt里有这么一段代码:

CMAKE_MINIMUM_REQUIRED (VERSION 3.0)

SET (PROJECT_NAME "Demo")

IF (WIN32)

IF (${CMAKE_GENERATOR} STREQUAL "Visual Studio 10 2010")

SET (PROJECT_SUFFIX "_vc10_win32")

SET (VS_PLATFORM "vs10")

SET (PLATFORM "vc10")

SET (ARCH "Win32")

ELSEIF (${CMAKE_GENERATOR} STREQUAL "Visual Studio 10 2010 Win64")

SET (PROJECT_SUFFIX "_vc10_x64")

SET (VS_PLATFORM "vs10")

SET (PLATFORM "vc10")

SET (ARCH "x64")

ELSEIF (${CMAKE_GENERATOR} STREQUAL "Visual Studio 11 2012")

SET (PROJECT_SUFFIX "_vc11_win32")

SET (VS_PLATFORM "vs11")

SET (PLATFORM "vc11")

SET (ARCH "Win32")

ELSEIF (${CMAKE_GENERATOR} STREQUAL "Visual Studio 11 2012 Win64")

SET (PROJECT_SUFFIX "_vc11_x64")

SET (VS_PLATFORM "vs11")

SET (PLATFORM "vc11")

SET (ARCH "x64")

ELSEIF (${CMAKE_GENERATOR} STREQUAL "Visual Studio 12 2013")

SET (PROJECT_SUFFIX "_vc12_win32")

SET (VS_PLATFORM "vs12")

SET (PLATFORM "vc12")

SET (ARCH "Win32")

ELSEIF (${CMAKE_GENERATOR} STREQUAL "Visual Studio 12 2013 Win64")

SET (PROJECT_SUFFIX "_vc12_x64")

SET (VS_PLATFORM "vs12")

SET (PLATFORM "vc12")

SET (ARCH "x64")

ELSE ()

MESSAGE (FATAL_ERROR "Invalid or unsupported generator, CMake will exit.")

ENDIF ()

ENDIF ()

首先我安装了CMake并配置了环境变量,版本信息如下:

cmake --version

cmake version 3.28.0-rc4

然后我安装了必要的MSBuild工具,版本是:

MSBuild /version

Microsoft (R) Build Engine version 12.0.40629.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

12.0.40629.0

之后我尝试构建这个Demo:

cmake -G "Visual Studio 12 2013 Win64" ..

结果遇到了错误,输出如下:

CMake Deprecation Warning at CMakeLists.txt:4 (CMAKE_MINIMUM_REQUIRED):
Compatibility with CMake < 3.5 will be removed from a future version of CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions.

CMake Error at CMakeLists.txt:48 (PROJECT):
Failed to run MSBuild command:
C:/Program Files (x86)/MSBuild/12.0/bin/MSBuild.exe
to get the value of VCTargetsPath:
Microsoft (R) Build Engine version 12.0.40629.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 11/20/2023 9:33:54 AM.
Project "Demo\build\CMakeFiles\3.28.0-rc4\VCTargetsPath.vcxproj" on node 1 (default targets).
Demo\build\CMakeFiles\3.28.0-rc4\VCTargetsPath.vcxproj(14,2): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "Demo\build\CMakeFiles\3.28.0-rc4\VCTargetsPath.vcxproj" (default targets) -- FAILED.

Build FAILED.

"Demo\build\CMakeFiles\3.28.0-rc4\VCTargetsPath.vcxproj" (default target) (1) -> Demo\build\CMakeFiles\3.28.0-rc4\VCTargetsPath.vcxproj(14,2): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.26
Exit code: 1

-- Configuring incomplete, errors occurred!

需要说明的是,一开始我并没有安装Visual Studio 2013,但安装之后,我在所有目录里都找不到报错里提到的C:\Microsoft.Cpp.Default.props文件。

有没有大佬能指点一下我该怎么解决这个问题?提前谢谢大家了!

备注:内容来源于stack exchange,提问作者Danny Brent

火山引擎 最新活动