要使用您自己的属性表进行此设置,项目 (.vcxproj)必须在Microsoft.Cpp.Default.props
.
否则,项目级别的属性看起来不错,但不是用于 .c(pp) 的 CL 任务的属性。
例如,假设以下D:\shared\my-customization.props
工作表:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<MY_CUSTOMIZATION_PREAMBLE>1</MY_CUSTOMIZATION_PREAMBLE>
</PropertyGroup>
<PropertyGroup>
<WholeProgramOptimization>false</WholeProgramOptimization>
// some others settings suffers from the same restrictions
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<UseDebugLibraries Condition="'$(Configuration)'!='Release'">true</UseDebugLibraries>
<UseDebugLibraries Condition="'$(Configuration)'=='Release'">false</UseDebugLibraries>
<_PropertySheetDisplayName>MyCustomization preamble</_PropertySheetDisplayName>
</PropertyGroup>
</Project>
要在您的多个项目中共享它们,必须将其包含在他们的 .vcxproj 中,如下所示:
[...]
<PropertyGroup Label="Globals">
[...]
</PropertyGroup>
<Import Project="D:\my-customization.props" Condition="'$(MY_CUSTOMIZATION_PREAMBLE)' == ''" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
[...]
</PropertyGroup>
[...]
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
[ usual location to import the property sheet ]