Skip to content

Commit bc67a22

Browse files
author
ejaquay
committed
static build libcommon if USE_STATIC_LIB is set
USE_STATIC_LIB will generate static libcommon.lib instead of libcommon.vcc DLL. Vcc.exe and hardware cart .dlls will be linked to libcommon.lib instead of libcommon.vcc
1 parent df53cca commit bc67a22

File tree

6 files changed

+47
-23
lines changed

6 files changed

+47
-23
lines changed

libcommon/include/vcc/detail/exports.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
#pragma once
1919

2020

21+
#ifdef USE_STATIC_LIB
22+
#define LIBCOMMON_EXPORT
23+
#else
2124
#ifdef LIBCOMMON_EXPORTS
2225
#define LIBCOMMON_EXPORT __declspec(dllexport)
2326
#else
2427
#define LIBCOMMON_EXPORT __declspec(dllimport)
2528
#endif
29+
#endif

libcommon/libcommon.vcxproj

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@
2323
</PropertyGroup>
2424
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2525
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
26-
<ConfigurationType>DynamicLibrary</ConfigurationType>
26+
<ConfigurationType Condition="'$(USE_STATIC_LIB)' == 'true'">StaticLibrary</ConfigurationType>
27+
<ConfigurationType Condition="'$(USE_STATIC_LIB)' != 'true'">DynamicLibrary</ConfigurationType>
2728
<UseDebugLibraries>true</UseDebugLibraries>
2829
<PlatformToolset>v143</PlatformToolset>
2930
<CharacterSet>MultiByte</CharacterSet>
3031
</PropertyGroup>
3132
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'" Label="Configuration">
32-
<ConfigurationType>DynamicLibrary</ConfigurationType>
33+
<ConfigurationType Condition="'$(USE_STATIC_LIB)' == 'true'">StaticLibrary</ConfigurationType>
34+
<ConfigurationType Condition="'$(USE_STATIC_LIB)' != 'true'">DynamicLibrary</ConfigurationType>
3335
<CharacterSet>MultiByte</CharacterSet>
3436
<PlatformToolset>v141_xp</PlatformToolset>
3537
</PropertyGroup>
3638
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
37-
<ConfigurationType>DynamicLibrary</ConfigurationType>
39+
<ConfigurationType Condition="'$(USE_STATIC_LIB)' == 'true'">StaticLibrary</ConfigurationType>
40+
<ConfigurationType Condition="'$(USE_STATIC_LIB)' != 'true'">DynamicLibrary</ConfigurationType>
3841
<UseDebugLibraries>false</UseDebugLibraries>
3942
<PlatformToolset>v143</PlatformToolset>
4043
<WholeProgramOptimization>true</WholeProgramOptimization>
@@ -61,49 +64,57 @@
6164
<Import Project="..\vss-release.props" />
6265
</ImportGroup>
6366
<PropertyGroup Label="UserMacros" />
64-
6567
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
66-
<TargetExt>.vcc</TargetExt>
67-
<OutDir>$(SolutionDir)__obj\$(Platform)\$(Configuration)\vcc\out\</OutDir>
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>
6871
</PropertyGroup>
6972
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
7073
<LibraryPath>C:\Program Files %28x86%29\Windows Kits\8.1\Lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
71-
<TargetExt>.vcc</TargetExt>
72-
<OutDir>$(SolutionDir)__obj\$(Platform)\$(Configuration)\vcc\out\</OutDir>
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>
7377
</PropertyGroup>
7478
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
75-
<TargetExt>.vcc</TargetExt>
76-
<OutDir>$(SolutionDir)__obj\$(Platform)\$(Configuration)\vcc\out\</OutDir>
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>
7782
</PropertyGroup>
7883
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7984
<ClCompile>
80-
<PreprocessorDefinitions>WIN32;_DEBUG;LIBCOMMON_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
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>
8188
</ClCompile>
8289
<Link>
83-
<LinkDLL>true</LinkDLL>
90+
<LinkDLL Condition="'$(USE_STATIC_LIB)' != 'true'">true</LinkDLL>
8491
<AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
8592
</Link>
8693
</ItemDefinitionGroup>
8794
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Legacy|Win32'">
8895
<ClCompile>
89-
<PreprocessorDefinitions>WIN32;_USRDLL;LIBCOMMON_EXPORTS;_LEGACY_VCC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
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>
9099
<AdditionalOptions>/arch:SSE</AdditionalOptions>
91100
</ClCompile>
92101
<ResourceCompile>
93102
<Culture>0x0409</Culture>
94103
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
95104
</ResourceCompile>
96105
<Link>
97-
<LinkDLL>true</LinkDLL>
106+
<LinkDLL Condition="'$(USE_STATIC_LIB)' != 'true'">true</LinkDLL>
98107
<AdditionalDependencies>Shlwapi.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
99108
</Link>
100109
</ItemDefinitionGroup>
101110
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
102111
<ClCompile>
103-
<PreprocessorDefinitions>WIN32;NDEBUG;LIBCOMMON_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
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>
104115
</ClCompile>
105116
<Link>
106-
<LinkDLL>true</LinkDLL>
117+
<LinkDLL Condition="'$(USE_STATIC_LIB)' != 'true'">true</LinkDLL>
107118
<AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
108119
</Link>
109120
</ItemDefinitionGroup>

libcommon/src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
HINSTANCE gModuleInstance = nullptr;
77

8-
8+
#ifndef USE_STATIC_LIB
99
BOOL APIENTRY DllMain(HMODULE module_handle, DWORD reason, LPVOID reserved)
1010
{
1111
if(reason == DLL_PROCESS_ATTACH)
@@ -14,4 +14,5 @@ BOOL APIENTRY DllMain(HMODULE module_handle, DWORD reason, LPVOID reserved)
1414
}
1515

1616
return TRUE;
17-
}
17+
}
18+
#endif

vcc-base.props

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- This is included first for release, legacy, and debug builds in every VCC project -->
23
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
34
<ImportGroup Label="PropertySheets" />
45
<PropertyGroup Label="UserMacros" />
@@ -12,13 +13,16 @@
1213
<LanguageStandard>stdcpp17</LanguageStandard>
1314
<WarningLevel>Level3</WarningLevel>
1415
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
16+
<PreprocessorDefinitions Condition="'$(USE_STATIC_LIB)' == 'true'">USE_STATIC_LIB=true;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1517
<BrowseInformation>true</BrowseInformation>
1618
<AdditionalIncludeDirectories>$(SolutionDir)libcommon/include</AdditionalIncludeDirectories>
1719
</ClCompile>
1820
<Link>
21+
<AdditionalDependencies Condition="'$(USE_STATIC_LIB)' == 'true' and '$(ProjectName)' != 'libcommon'">libcommon.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
22+
<AdditionalLibraryDirectories Condition="'$(USE_STATIC_LIB)' == 'true' and '$(ProjectName)' != 'libcommon'">$(SolutionDir)__obj\$(Platform)\$(Configuration)\libcommon\out\</AdditionalLibraryDirectories>
1923
<SubSystem>Windows</SubSystem>
2024
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
2125
</Link>
2226
</ItemDefinitionGroup>
2327
<ItemGroup />
24-
</Project>
28+
</Project>

vcc-debug.props

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- This is included for debug builds in every VCC project -->
23
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
34
<ImportGroup Label="PropertySheets" />
45
<PropertyGroup Label="UserMacros" />
@@ -9,7 +10,8 @@
910
<ClCompile />
1011
<ClCompile>
1112
<Optimization>Disabled</Optimization>
12-
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
13+
<RuntimeLibrary Condition="'$(USE_STATIC_LIB)' == 'true'">MultiThreadedDebug</RuntimeLibrary>
14+
<RuntimeLibrary Condition="'$(USE_STATIC_LIB)' != 'true'">MultiThreadedDebugDLL</RuntimeLibrary>
1315
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
1416
<BrowseInformation>true</BrowseInformation>
1517
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -22,4 +24,4 @@
2224
<Link />
2325
</ItemDefinitionGroup>
2426
<ItemGroup />
25-
</Project>
27+
</Project>

vss-release.props

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--> This is included for non debug builds in every VCC project -->
23
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
34
<ImportGroup Label="PropertySheets" />
45
<PropertyGroup Label="UserMacros" />
@@ -9,7 +10,8 @@
910
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1011
<StringPooling>true</StringPooling>
1112
<FunctionLevelLinking>true</FunctionLevelLinking>
12-
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
13+
<RuntimeLibrary Condition="'$(USE_STATIC_LIB)' == 'true'">MultiThreaded</RuntimeLibrary>
14+
<RuntimeLibrary Condition="'$(USE_STATIC_LIB)' != 'true'">MultiThreadedDLL</RuntimeLibrary>
1315
</ClCompile>
1416
<ResourceCompile>
1517
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -19,4 +21,4 @@
1921
</Link>
2022
</ItemDefinitionGroup>
2123
<ItemGroup />
22-
</Project>
24+
</Project>

0 commit comments

Comments
 (0)