Skip to content

Commit d48b68b

Browse files
author
ejaquay
committed
Use LinkageType property to control static library builds
Create LinkageType property "Dynamic" or "Static" based on USE_STATIC_LIB enviroment variable instead of checking the variable each time the property would be needed. if USE_STATIC_LIB == true a static libcommon build is done. Otherwise a dynamic libcommon build is done.
1 parent 1cb2bdc commit d48b68b

File tree

4 files changed

+38
-46
lines changed

4 files changed

+38
-46
lines changed

libcommon/libcommon.vcxproj

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,23 @@
2222
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
2323
</PropertyGroup>
2424
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
25+
<Import Project="..\vcc-base.props" />
26+
<PropertyGroup>
27+
<ConfigurationType Condition="'$(LinkageType)' == 'Static'">StaticLibrary</ConfigurationType>
28+
<ConfigurationType Condition="'$(LinkageType)' == 'Dynamic'">DynamicLibrary</ConfigurationType>
29+
</PropertyGroup>
2530
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
26-
<ConfigurationType Condition="'$(USE_STATIC_LIB)' == 'true'">StaticLibrary</ConfigurationType>
27-
<ConfigurationType Condition="'$(USE_STATIC_LIB)' != 'true'">DynamicLibrary</ConfigurationType>
2831
<UseDebugLibraries>true</UseDebugLibraries>
2932
<PlatformToolset>v143</PlatformToolset>
3033
<CharacterSet>MultiByte</CharacterSet>
3134
</PropertyGroup>
3235
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="Configuration">
33-
<ConfigurationType Condition="'$(USE_STATIC_LIB)' == 'true'">StaticLibrary</ConfigurationType>
34-
<ConfigurationType Condition="'$(USE_STATIC_LIB)' != 'true'">DynamicLibrary</ConfigurationType>
3536
<CharacterSet>MultiByte</CharacterSet>
3637
<PlatformToolset>v141_xp</PlatformToolset>
3738
</PropertyGroup>
3839
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
39-
<ConfigurationType Condition="'$(USE_STATIC_LIB)' == 'true'">StaticLibrary</ConfigurationType>
40-
<ConfigurationType Condition="'$(USE_STATIC_LIB)' != 'true'">DynamicLibrary</ConfigurationType>
4140
<UseDebugLibraries>false</UseDebugLibraries>
4241
<PlatformToolset>v143</PlatformToolset>
43-
<WholeProgramOptimization>true</WholeProgramOptimization>
4442
<CharacterSet>MultiByte</CharacterSet>
4543
</PropertyGroup>
4644
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -50,71 +48,60 @@
5048
</ImportGroup>
5149
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
5250
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
53-
<Import Project="..\vcc-base.props" />
5451
<Import Project="..\vcc-debug.props" />
5552
</ImportGroup>
5653
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
5754
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
58-
<Import Project="..\vcc-base.props" />
5955
<Import Project="..\vss-release.props" />
6056
</ImportGroup>
6157
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
6258
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63-
<Import Project="..\vcc-base.props" />
6459
<Import Project="..\vss-release.props" />
6560
</ImportGroup>
6661
<PropertyGroup Label="UserMacros" />
67-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
68-
<OutDir Condition="'$(USE_STATIC_LIB)' == 'true'">$(SolutionDir)__obj\$(Platform)\$(Configuration)\libcommon\out\</OutDir>
69-
<OutDir Condition="'$(USE_STATIC_LIB)' != 'true'">$(SolutionDir)__obj\$(Platform)\$(Configuration)\vcc\out\</OutDir>
70-
<TargetExt Condition="'$(USE_STATIC_LIB)' == 'true'">.vcc</TargetExt>
62+
<PropertyGroup>
63+
<ClCompile>
64+
<WholeProgramOptimization Condition="'$(LinkageType)' == 'Static'">true</WholeProgramOptimization>
65+
<WholeProgramOptimization Condition="'$(LinkageType)' == 'Dynamic'">false</WholeProgramOptimization>
66+
</ClCompile>
67+
<OutDir Condition="'$(LinkageType)' == 'Dynamic'">$(SolutionDir)__obj\$(Platform)\$(LinkTypeSubDir)\$(Configuration)\vcc\out\</OutDir>
68+
<TargetExt Condition="'$(LinkageType)' == 'Dynamic'">.vcc</TargetExt>
7169
</PropertyGroup>
7270
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
73-
<LibraryPath>C:\Program Files %28x86%29\Windows Kits\8.1\Lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
74-
<OutDir Condition="'$(USE_STATIC_LIB)' == 'true'">$(SolutionDir)__obj\$(Platform)\$(Configuration)\libcommon\out\</OutDir>
75-
<OutDir Condition="'$(USE_STATIC_LIB)' != 'true'">$(SolutionDir)__obj\$(Platform)\$(Configuration)\vcc\out\</OutDir>
76-
<TargetExt Condition="'$(USE_STATIC_LIB)' != 'true'">.vcc</TargetExt>
77-
</PropertyGroup>
78-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79-
<OutDir Condition="'$(USE_STATIC_LIB)' == 'true'">$(SolutionDir)__obj\$(Platform)\$(Configuration)\libcommon\out\</OutDir>
80-
<OutDir Condition="'$(USE_STATIC_LIB)' != 'true'">$(SolutionDir)__obj\$(Platform)\$(Configuration)\vcc\out\</OutDir>
81-
<TargetExt Condition="'$(USE_STATIC_LIB)' != 'true'">.vcc</TargetExt>
71+
<LibraryPath>"$(ProgramFiles(x86))\Windows Kits\8.1\Lib\winv6.3\um\x86;$(LibraryPath)"</LibraryPath>
8272
</PropertyGroup>
8373
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
8474
<ClCompile>
85-
<PreprocessorDefinitions Condition="'$(USE_STATIC_LIB)' != 'true'">WIN32;_DEBUG;LIBCOMMON_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
86-
<PreprocessorDefinitions Condition="'$(USE_STATIC_LIB)' == 'true'">WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
87-
<WholeProgramOptimization Condition="'$(USE_STATIC_LIB)' != 'true'">false</WholeProgramOptimization>
75+
<PreprocessorDefinitions Condition="'$(LinkageType)' == 'Dynamic'">WIN32;_DEBUG;LIBCOMMON_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
76+
<PreprocessorDefinitions Condition="'$(LinkageType)' == 'Static'">WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
8877
</ClCompile>
8978
<Link>
90-
<LinkDLL Condition="'$(USE_STATIC_LIB)' != 'true'">true</LinkDLL>
79+
<LinkDLL Condition="'$(LinkageType)' == 'Dynamic'">true</LinkDLL>
9180
<AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
9281
</Link>
9382
</ItemDefinitionGroup>
9483
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
9584
<ClCompile>
96-
<PreprocessorDefinitions Condition="'$(USE_STATIC_LIB)' != 'true'">WIN32;_USRDLL;LIBCOMMON_EXPORTS;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
97-
<PreprocessorDefinitions Condition="'$(USE_STATIC_LIB)' == 'true'">WIN32;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
98-
<WholeProgramOptimization Condition="'$(USE_STATIC_LIB)' != 'true'">false</WholeProgramOptimization>
85+
<PreprocessorDefinitions Condition="'$(LinkageType)' == 'Dynamic'">WIN32;_USRDLL;LIBCOMMON_EXPORTS;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
86+
<PreprocessorDefinitions Condition="'$(LinkageType)' == 'Static'">WIN32;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9987
<AdditionalOptions>/arch:SSE</AdditionalOptions>
10088
</ClCompile>
10189
<ResourceCompile>
10290
<Culture>0x0409</Culture>
10391
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
10492
</ResourceCompile>
10593
<Link>
106-
<LinkDLL Condition="'$(USE_STATIC_LIB)' != 'true'">true</LinkDLL>
94+
<LinkDLL Condition="'$(LinkageType)' == 'Dynamic'">true</LinkDLL>
10795
<AdditionalDependencies>Shlwapi.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
10896
</Link>
10997
</ItemDefinitionGroup>
11098
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
11199
<ClCompile>
112-
<PreprocessorDefinitions Condition="'$(USE_STATIC_LIB)' != 'true'">WIN32;NDEBUG;LIBCOMMON_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
113-
<PreprocessorDefinitions Condition="'$(USE_STATIC_LIB)' == 'true'">WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
114-
<WholeProgramOptimization Condition="'$(USE_STATIC_LIB)' != 'true'">false</WholeProgramOptimization>
100+
<PreprocessorDefinitions Condition="'$(LinkageType)' == 'Dynamic'">WIN32;NDEBUG;LIBCOMMON_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
101+
<PreprocessorDefinitions Condition="'$(LinkageType)' == 'Static'">WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
115102
</ClCompile>
116103
<Link>
117-
<LinkDLL Condition="'$(USE_STATIC_LIB)' != 'true'">true</LinkDLL>
104+
<LinkDLL Condition="'$(LinkageType)' == 'Dynamic'">true</LinkDLL>
118105
<AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
119106
</Link>
120107
</ItemDefinitionGroup>

vcc-base.props

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- This is included first for release, legacy, and debug builds in every VCC project -->
2+
<!-- This is included first in every VCC project -->
33
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
44
<ImportGroup Label="PropertySheets" />
55
<PropertyGroup Label="UserMacros" />
66
<PropertyGroup>
7-
<OutDir>$(SolutionDir)__obj\$(Platform)\$(Configuration)\$(ProjectName)\out\</OutDir>
8-
<IntDir>$(SolutionDir)__obj\$(Platform)\$(Configuration)\$(ProjectName)\int\</IntDir>
7+
<!-- Define linkage type: Static or Dynamic, default is Dynamic -->
8+
<LinkageType Condition="'$(USE_STATIC_LIB)' == 'true'">Static</LinkageType>
9+
<LinkageType Condition="'$(LinkageType)' != 'Static'">Dynamic</LinkageType>
10+
<!-- static builds go to their own subdirectory -->
11+
<LinkTypeSubDir Condition="'$(LinkageType)' == 'Static'">Static</LinkTypeSubDir>
12+
<LinkTypeSubDir Condition="'$(LinkageType)' == 'Dynamic'"></LinkTypeSubDir>
13+
<OutDir>$(SolutionDir)__obj\$(Platform)\$(LinkTypeSubDir)\$(Configuration)\$(ProjectName)\out\</OutDir>
14+
<IntDir>$(SolutionDir)__obj\$(Platform)\$(LinkTypeSubDir)\$(Configuration)\$(ProjectName)\int\</IntDir>
915
<LinkIncremental>false</LinkIncremental>
1016
</PropertyGroup>
11-
<ItemDefinitionGroup Condition="'$(USE_STATIC_LIB)' != 'true'">
17+
<ItemDefinitionGroup Condition="'$(LinkageType)' == 'Dynamic'">
1218
<ClCompile>
1319
<LanguageStandard>stdcpp17</LanguageStandard>
1420
<WarningLevel>Level3</WarningLevel>
15-
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
21+
<PreprocessorDefinitions>USE_STATIC_LIB=false;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1622
<BrowseInformation>true</BrowseInformation>
1723
<AdditionalIncludeDirectories>$(SolutionDir)libcommon/include</AdditionalIncludeDirectories>
1824
</ClCompile>
@@ -21,7 +27,7 @@
2127
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
2228
</Link>
2329
</ItemDefinitionGroup>
24-
<ItemDefinitionGroup Condition="'$(USE_STATIC_LIB)' == 'true'">
30+
<ItemDefinitionGroup Condition="'$(LinkageType)' == 'Static'">
2531
<ClCompile>
2632
<LanguageStandard>stdcpp17</LanguageStandard>
2733
<WarningLevel>Level3</WarningLevel>
@@ -39,6 +45,5 @@
3945
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
4046
</Link>
4147
</ItemDefinitionGroup>
42-
4348
<ItemGroup />
4449
</Project>

vcc-debug.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<ClCompile />
1111
<ClCompile>
1212
<Optimization>Disabled</Optimization>
13-
<RuntimeLibrary Condition="'$(USE_STATIC_LIB)' == 'true'">MultiThreadedDebug</RuntimeLibrary>
14-
<RuntimeLibrary Condition="'$(USE_STATIC_LIB)' != 'true'">MultiThreadedDebugDLL</RuntimeLibrary>
13+
<RuntimeLibrary Condition="'$(LinkageType)' == 'Static'">MultiThreadedDebug</RuntimeLibrary>
14+
<RuntimeLibrary Condition="'$(LinkageType)' == 'Dynamic'">MultiThreadedDebugDLL</RuntimeLibrary>
1515
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
1616
<BrowseInformation>true</BrowseInformation>
1717
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>

vss-release.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1111
<StringPooling>true</StringPooling>
1212
<FunctionLevelLinking>true</FunctionLevelLinking>
13-
<RuntimeLibrary Condition="'$(USE_STATIC_LIB)' == 'true'">MultiThreaded</RuntimeLibrary>
14-
<RuntimeLibrary Condition="'$(USE_STATIC_LIB)' != 'true'">MultiThreadedDLL</RuntimeLibrary>
13+
<RuntimeLibrary Condition="'$(LinkageType)' == 'Static'">MultiThreaded</RuntimeLibrary>
14+
<RuntimeLibrary Condition="'$(LinkageType)' == 'Dynamic'">MultiThreadedDLL</RuntimeLibrary>
1515
</ClCompile>
1616
<ResourceCompile>
1717
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>

0 commit comments

Comments
 (0)