Merge pull request #127 from MinGW-caffe/master

try to avoid the error "conflicting declaration 'typedef DWORD pthread_t'" etc. in MinGW
diff --git a/AUTHORS b/AUTHORS
index 59d027e..347ae24 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -10,9 +10,12 @@
 
 Abhishek Dasgupta <abhi2743@gmail.com>
 Abhishek Parmar <abhishek@orng.net>
+Andy Ying <andy@trailofbits.com>
 Brian Silverman <bsilver16384@gmail.com>
 Google Inc.
+Guillaume Dumont <dumont.guillaume@gmail.com>
 Michael Tanner <michael@tannertaxpro.com>
+MiniLight <MiniLightAR@Gmail.com>
 romange <romange@users.noreply.github.com>
 Sergiu Dotenco <sergiu.dotenco@th-nuernberg.de>
 tbennun <tbennun@gmail.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1429590..dc446b9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -101,8 +101,14 @@
 check_function_exists (sigaction HAVE_SIGACTION)
 check_function_exists (sigaltstack HAVE_SIGALSTACK)
 
-check_cxx_compiler_flag (-Wno-deprecated HAVE_NO_DEPRECATED)
-check_cxx_compiler_flag (-Wno-unnamed-type-template-args
+# NOTE gcc does not fail if you pass a non-existent -Wno-* option as an
+# argument. However, it will happily fail if you pass the corresponding -W*
+# option. So, we check whether options that disable warnings exist by testing
+# the availability of the corresponding option that enables the warning. This
+# eliminates the need to check for compiler for several (mainly Clang) options.
+
+check_cxx_compiler_flag (-Wdeprecated HAVE_NO_DEPRECATED)
+check_cxx_compiler_flag (-Wunnamed-type-template-args
     HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS)
 
 # NOTE: Cannot use check_function_exists here since >=vc-14.0 can define
@@ -368,10 +374,14 @@
   )
 endif (WIN32)
 
+add_compile_options ($<$<BOOL:${HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS}>:-Wno-unnamed-type-template-args>)
+
 add_library (glog
   ${GLOG_SRCS}
 )
 
+set_target_properties (glog PROPERTIES POSITION_INDEPENDENT_CODE ON)
+
 if (UNWIND_LIBRARY)
   target_link_libraries (glog PUBLIC ${UNWIND_LIBRARY})
 endif (UNWIND_LIBRARY)
@@ -385,12 +395,8 @@
     HAVE_SNPRINTF)
 endif (WIN32 AND HAVE_SNPRINTF)
 
-if (HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS)
-  target_compile_options (glog PUBLIC -Wno-unnamed-type-template-args)
-endif (HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS)
-
 if (gflags_FOUND)
-  target_include_directories (glog PUBLIC ${gflags_INCLUDE_DIR})
+  target_include_directories (glog PUBLIC $<BUILD_INTERFACE:${gflags_INCLUDE_DIR}>)
   target_link_libraries (glog PUBLIC ${gflags_LIBRARIES})
 
   if (NOT BUILD_SHARED_LIBS)
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index bf413f8..40864c1 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -24,11 +24,14 @@
 
 Abhishek Dasgupta <abhi2743@gmail.com>
 Abhishek Parmar <abhishek@orng.net>
+Andy Ying <andy@trailofbits.com>
 Brian Silverman <bsilver16384@gmail.com>
 Fumitoshi Ukai <ukai@google.com>
+Guillaume Dumont <dumont.guillaume@gmail.com>
 Håkan L. S. Younes <hyounes@google.com>
 Ivan Penkov <ivanpe@google.com>
 Michael Tanner <michael@tannertaxpro.com>
+MiniLight <MiniLightAR@Gmail.com>
 Peter Collingbourne <pcc@google.com>
 romange <romange@users.noreply.github.com>
 Sergiu Dotenco <sergiu.dotenco@th-nuernberg.de>
diff --git a/src/config.h.in b/src/config.h.in
index e41635a..8190f23 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -178,12 +178,3 @@
 
 /* Puts following code inside the Google namespace */
 #undef _START_GOOGLE_NAMESPACE_
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
diff --git a/src/demangle.h b/src/demangle.h
index 2653029..991b6ff 100644
--- a/src/demangle.h
+++ b/src/demangle.h
@@ -71,6 +71,7 @@
 #define BASE_DEMANGLE_H_
 
 #include "config.h"
+#include "glog/logging.h"
 
 _START_GOOGLE_NAMESPACE_
 
diff --git a/src/logging.cc b/src/logging.cc
index ec9eef1..0b5e6ee 100644
--- a/src/logging.cc
+++ b/src/logging.cc
@@ -825,6 +825,7 @@
   }
   MutexLock l(&sink_mutex_);
   delete sinks_;
+  sinks_ = NULL;
 }
 
 namespace {