Commit 5ea707adea4146a64c38106a9bad11b01f74f0ef

Timothy Gu 2015-03-15T16:35:22

Define SHARED when building shared library

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6dcf8a3..972ffb4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,10 @@ option(BUILD_TESTS "tests?" OFF)
 set(headers dlfcn.h)
 set(sources dlfcn.c)
 
+if (BUILD_SHARED_LIBS)
+  add_definitions(-DSHARED)
+endif (BUILD_SHARED_LIBS)
+
 add_library(dl ${sources})
 
 install (TARGETS dl RUNTIME DESTINATION bin
diff --git a/Makefile b/Makefile
index 2b03051..0f32932 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ CFLAGS=-Wall -O3 -fomit-frame-pointer
 ifeq ($(BUILD_SHARED),yes)
 	TARGETS += libdl.dll
 	SHFLAGS += -Wl,--out-implib,libdl.dll.a
+	CFLAGS  += -DSHARED
 	INSTALL += shared-install
 endif
 ifeq ($(BUILD_STATIC),yes)
diff --git a/visual-studio/12/dl/dl.vcxproj b/visual-studio/12/dl/dl.vcxproj
index 6062cad..cea69bd 100644
--- a/visual-studio/12/dl/dl.vcxproj
+++ b/visual-studio/12/dl/dl.vcxproj
@@ -125,6 +125,7 @@
       <WarningLevel>Level4</WarningLevel>
       <Optimization>Disabled</Optimization>
       <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>SHARED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -155,6 +156,7 @@
       <WarningLevel>Level4</WarningLevel>
       <Optimization>Disabled</Optimization>
       <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>SHARED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -195,6 +197,7 @@
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>SHARED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
@@ -209,6 +212,7 @@
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>SHARED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>