From dd8b098387f45289c2faae7b1cddf51a3d7eea96 Mon Sep 17 00:00:00 2001
From: Camilla Berglund <elmindreda@elmindreda.org>
Date: Thu, 29 Mar 2012 14:06:26 +0200
Subject: [PATCH 1/2] Moved _GLFW_BUILD_DLL into configuration header.

---
 CMakeLists.txt     | 7 +++++++
 src/CMakeLists.txt | 2 +-
 src/cocoa_init.m   | 6 +++++-
 src/config.h.in    | 3 +++
 src/x11_init.c     | 3 +++
 5 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 57f4d16b..db1e363a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,6 +22,13 @@ if (CMAKE_COMPILER_IS_GNUCC)
     add_definitions(-Wall)
 endif()
 
+#--------------------------------------------------------------------
+# Export shared library / dynamic library / DLL build option
+#--------------------------------------------------------------------
+if (BUILD_SHARED_LIBS)
+    set(_GLFW_BUILD_DLL 1)
+endif()
+
 #--------------------------------------------------------------------
 # Detect and select target platform
 #--------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ae72cda7..1b8a26e3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -36,7 +36,7 @@ if (BUILD_SHARED_LIBS)
     if (_GLFW_WIN32_WGL)
         # The GLFW DLL needs a special compile-time macro and import library name
         set_target_properties(glfw PROPERTIES 
-                              COMPILE_DEFINITIONS "_GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM"
+                              COMPILE_DEFINITIONS "_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM"
                               PREFIX ""
                               IMPORT_PREFIX ""
                               IMPORT_SUFFIX "dll.lib")
diff --git a/src/cocoa_init.m b/src/cocoa_init.m
index 16bd98eb..594266d1 100644
--- a/src/cocoa_init.m
+++ b/src/cocoa_init.m
@@ -152,7 +152,11 @@ int _glfwPlatformTerminate(void)
 
 const char* _glfwPlatformGetVersionString(void)
 {
-    const char* version = _GLFW_VERSION_FULL " Cocoa";
+    const char* version = _GLFW_VERSION_FULL
+#if defined(_GLFW_BUILD_DLL)
+        " dynamic"
+#endif
+        ;
 
     return version;
 }
diff --git a/src/config.h.in b/src/config.h.in
index 46a6e2aa..c21212e7 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -42,6 +42,9 @@
 // Define this to 1 if building GLFW for Cocoa/NSOpenGL
 #cmakedefine _GLFW_COCOA_NSGL
 
+// Define this to 1 if building as a shared library / dynamic library / DLL
+#cmakedefine _GLFW_BUILD_DLL       1
+
 // Define this to 1 if XRandR is available
 #cmakedefine _GLFW_HAS_XRANDR      1
 // Define this to 1 if Xf86VidMode is available
diff --git a/src/x11_init.c b/src/x11_init.c
index d57af27e..9cec8e22 100644
--- a/src/x11_init.c
+++ b/src/x11_init.c
@@ -660,6 +660,9 @@ const char* _glfwPlatformGetVersionString(void)
         " Linux-joystick-API"
 #else
         " no-joystick-support"
+#endif
+#if defined(_GLFW_BUILD_DLL)
+        " shared"
 #endif
         ;
 

From fcf54b4b27495b235c32852a319ca0efa2d5a95c Mon Sep 17 00:00:00 2001
From: Camilla Berglund <elmindreda@elmindreda.org>
Date: Thu, 29 Mar 2012 14:21:04 +0200
Subject: [PATCH 2/2] Moved dynamic loading macros to configuration header.

---
 CMakeLists.txt     | 3 +++
 src/CMakeLists.txt | 1 -
 src/config.h.in    | 5 +++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index db1e363a..089132f6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,6 +54,9 @@ if (_GLFW_WIN32_WGL)
     list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
     list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY})
 
+    set(_GLFW_NO_DLOAD_GDI32 ${BUILD_SHARED_LIBS})
+    set(_GLFW_NO_DLOAD_WINMM ${BUILD_SHARED_LIBS})
+
     if (BUILD_SHARED_LIBS)
         list(APPEND glfw_LIBRARIES winmm)
     endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1b8a26e3..01ff500c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -36,7 +36,6 @@ if (BUILD_SHARED_LIBS)
     if (_GLFW_WIN32_WGL)
         # The GLFW DLL needs a special compile-time macro and import library name
         set_target_properties(glfw PROPERTIES 
-                              COMPILE_DEFINITIONS "_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM"
                               PREFIX ""
                               IMPORT_PREFIX ""
                               IMPORT_SUFFIX "dll.lib")
diff --git a/src/config.h.in b/src/config.h.in
index c21212e7..b099dd9b 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -45,6 +45,11 @@
 // Define this to 1 if building as a shared library / dynamic library / DLL
 #cmakedefine _GLFW_BUILD_DLL       1
 
+// Define this to 1 to disable dynamic loading of gdi32
+#cmakedefine _GLFW_NO_DLOAD_GDI32  1
+// Define this to 1 to disable dynamic loading of winmm
+#cmakedefine _GLFW_NO_DLOAD_WINMM  1
+
 // Define this to 1 if XRandR is available
 #cmakedefine _GLFW_HAS_XRANDR      1
 // Define this to 1 if Xf86VidMode is available