我一直在从头开始制作vcxproj文件,以更好地了解msbuild。我的项目结构基本上是这样的:
$(MSBuildProjectDirectory)\src\main.cpp
$(MSBuildProjectDirectory)\src\stafx.cpp
$(MSBuildProjectDirectory)\include\stdafx.h
根据我的假设,我在vcxproj文件中对此进行了定义:
<ItemGroup>
<ClInclude Include="$(MSBuildProjectDirectory)\include\stdafx.h" />
</ItemGroup>
允许我从#include "stdafx.h"
调用main.cpp
,而不必指定相对路径(例如#include ..\include\stdafx.h
)。但是在构建项目时,出现一条失败消息,提示msbuild找不到stdafx.h
:
"C:\Projects\SDL2plusplus\SDL2PlusPlus.vcxproj" (default target) (1) ->
(ClCompile target) ->
C:\Projects\SDL2plusplus\src\stdafx.cpp(4): fatal error C1083: Cannot open include file: 'stdafx.h': No such file or direc tory [C:\Projects\SDL2plusplus\SDL2PlusPlus.vcxproj]
有没有一种方法可以在vcxproj文件中指定包含目录,从而避免将手动路径放入我的#include指令中?
答案 0 :(得分:0)
这是一个ClCompile任务,它属于ItemDefinitionGroup:
<ItemDefinitionGroup>
<ClCompile>
<!--<PrecompiledHeader>Use</PrecompiledHeader>-->
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(MSBuildProjectDirectory)\include;C:\vs_dev_lib\SDL2-2.0.8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>