From fcd849771a7bd15d81a82acccab3a6c3ccef3954 Mon Sep 17 00:00:00 2001
From: Shon Ferguson <shonferg@users.sourceforge.net>
Date: Sat, 5 May 2007 18:38:12 +0000
Subject: [PATCH] Changed the default linkage to DLL.  You now have to define
 NIFLIB_STATIC_LINK if you want to use static linking instead of having to
 define USE_NIFLIB_DLL if you want to use the DLL. Added a new Debug - DLL
 configuration. Static configurations now create either niflib_static.lib or
 niflib_static_debug.lib, while DLL configurations create niflib_dll.lib and
 niflib_dll_debug.lib along with niflib.dll and niflib_debug.dll.

---
 include/dll_export.h |  2 +-
 niflib.sln           | 15 ++++---
 niflib.vcproj        | 99 ++++++++++++++++++++++++++++++++++++++++----
 3 files changed, 101 insertions(+), 15 deletions(-)

diff --git a/include/dll_export.h b/include/dll_export.h
index 2b9963d1..d8bd6d33 100644
--- a/include/dll_export.h
+++ b/include/dll_export.h
@@ -12,7 +12,7 @@ All rights reserved.  Please see niflib.h for licence. */
 #endif
 
 // shared library: expose NIFLIB_API objects, hide NIFLIB_HIDDEN objects
-#ifdef USE_NIFLIB_DLL
+#ifndef NIFLIB_STATIC_LINK
 	// building swig wrapper
 	#if defined(SWIG)
 		#define NIFLIB_API
diff --git a/niflib.sln b/niflib.sln
index d299dab4..16cbe177 100644
--- a/niflib.sln
+++ b/niflib.sln
@@ -4,17 +4,20 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Niflib", "niflib.vcproj", "
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
+		Debug - DLL|Win32 = Debug - DLL|Win32
+		Debug - Static|Win32 = Debug - Static|Win32
 		Release - DLL|Win32 = Release - DLL|Win32
-		Release|Win32 = Release|Win32
+		Release - Static|Win32 = Release - Static|Win32
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug|Win32.ActiveCfg = Debug|Win32
-		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug|Win32.Build.0 = Debug|Win32
+		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug - DLL|Win32.ActiveCfg = Debug - DLL|Win32
+		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug - DLL|Win32.Build.0 = Debug - DLL|Win32
+		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug - Static|Win32.ActiveCfg = Debug - Static|Win32
+		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Debug - Static|Win32.Build.0 = Debug - Static|Win32
 		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release - DLL|Win32.ActiveCfg = Release - DLL|Win32
 		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release - DLL|Win32.Build.0 = Release - DLL|Win32
-		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release|Win32.ActiveCfg = Release|Win32
-		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release|Win32.Build.0 = Release|Win32
+		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release - Static|Win32.ActiveCfg = Release - Static|Win32
+		{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}.Release - Static|Win32.Build.0 = Release - Static|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/niflib.vcproj b/niflib.vcproj
index b9c9e11f..5ed78846 100644
--- a/niflib.vcproj
+++ b/niflib.vcproj
@@ -16,7 +16,7 @@
 	</ToolFiles>
 	<Configurations>
 		<Configuration
-			Name="Debug|Win32"
+			Name="Debug - Static|Win32"
 			OutputDirectory="$(ProjectDir)obj\$(ConfigurationName)"
 			IntermediateDirectory="$(ProjectDir)obj\$(ConfigurationName)"
 			ConfigurationType="4"
@@ -42,7 +42,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="$(ProjectDir)"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				PreprocessorDefinitions="NIFLIB_STATIC_LINK; WIN32;_DEBUG;_CONSOLE"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="1"
@@ -62,7 +62,7 @@
 			/>
 			<Tool
 				Name="VCLibrarianTool"
-				OutputFile="lib/niflib_debug.lib"
+				OutputFile="lib/niflib_static_debug.lib"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -81,7 +81,7 @@
 			/>
 		</Configuration>
 		<Configuration
-			Name="Release|Win32"
+			Name="Release - Static|Win32"
 			OutputDirectory="$(ProjectDir)obj\$(ConfigurationName)"
 			IntermediateDirectory="$(ProjectDir)obj\$(ConfigurationName)"
 			ConfigurationType="4"
@@ -109,7 +109,7 @@
 				Optimization="0"
 				WholeProgramOptimization="false"
 				AdditionalIncludeDirectories="$(ProjectDir)"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				PreprocessorDefinitions="NIFLIB_STATIC_LINK; WIN32;NDEBUG;_CONSOLE"
 				RuntimeLibrary="0"
 				UsePrecompiledHeader="0"
 				PrecompiledHeaderThrough=""
@@ -127,7 +127,7 @@
 			/>
 			<Tool
 				Name="VCLibrarianTool"
-				OutputFile="lib/niflib.lib"
+				OutputFile="lib/niflib_static.lib"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -173,7 +173,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="3"
 				AdditionalIncludeDirectories="$(ProjectDir)"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BUILDING_NIFLIB_DLL;USE_NIFLIB_DLL"
+				PreprocessorDefinitions="BUILDING_NIFLIB_DLL;WIN32;NDEBUG;_CONSOLE"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
 				PrecompiledHeaderThrough=""
@@ -219,6 +219,81 @@
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
+		<Configuration
+			Name="Debug - DLL|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="$(ProjectDir)"
+				PreprocessorDefinitions="BUILDING_NIFLIB_DLL;WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderThrough=""
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="bin\niflib_debug.dll"
+				ImportLibrary="lib/niflib_dll_debug.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
 	</Configurations>
 	<References>
 	</References>
@@ -248,7 +323,15 @@
 				RelativePath=".\src\niflib.cpp"
 				>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Debug - Static|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						PrecompiledHeaderThrough=""
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug - DLL|Win32"
 					>
 					<Tool
 						Name="VCCLCompilerTool"
-- 
GitLab