在项目属性> C/C++ > Optimization > Whole Program Optimization
中,我可以设置/GL
。
我可以在共享的属性表(/GL
文件)中启用/禁用.props
并以此为基础建立许多项目吗?
我已经尝试过:-
<PropertyGroup>
<WholeProgramOptimization
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
true
</WholeProgramOptimization>
但是,看起来没有效果。
我真的需要手动编辑每个项目的属性吗?
我正在使用VS2017版本15.3.0。
相关:Visual Studio property sheets: Why is Character Set missing?
答案 0 :(得分:0)
要使用自己的属性表进行此设置,必须在Microsoft.Cpp.Default.props
之前中将其包含在项目(.vcxproj)中。
否则,项目级别的属性将看起来不错,但.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 ]