Merge pull request #49 from sergiud/cmake-visibility

Fixed warning caused by policy CMP0063 introduced in CMake 3.3
diff --git a/AUTHORS b/AUTHORS
index 3adbe3a..72959a0 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -15,3 +15,4 @@
 romange <romange@users.noreply.github.com>
 Sergiu Dotenco <sergiu.dotenco@th-nuernberg.de>
 tbennun <tbennun@gmail.com>
+Teddy Reed <teddy@prosauce.org>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b2fa9e4..ecb1355 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,7 @@
 set (CPACK_PACKAGE_VERSION ${GLOG_VERSION})
 
 option (WITH_GFLAGS "Use gflags" ON)
+option (WITH_THREADS "Enable multithreading support" ON)
 
 list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
 
@@ -55,7 +56,9 @@
   endif (gflags_FOUND)
 endif (WITH_GFLAGS)
 
-find_package (Threads)
+if (WITH_THREADS)
+  find_package (Threads)
+endif (WITH_THREADS)
 
 check_include_file (dlfcn.h HAVE_DLFCN_H)
 check_include_file (execinfo.h HAVE_EXECINFO_H)
@@ -310,9 +313,13 @@
 
 set (SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
 
-if (Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
-  set (HAVE_PTHREAD 1)
-endif (Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
+if (WITH_THREADS AND Threads_FOUND)
+  if (CMAKE_USE_PTHREADS_INIT)
+    set (HAVE_PTHREAD 1)
+  endif (CMAKE_USE_PTHREADS_INIT)
+else (WITH_THREADS AND Threads_FOUND)
+  set (NO_THREADS 1)
+endif (WITH_THREADS AND Threads_FOUND)
 
 set (TEST_SRC_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\")
 
@@ -432,12 +439,6 @@
     "GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS=${_IMPORT}")
 endif (NOT BUILD_SHARED_LIBS)
 
-if (HAVE_PTHREAD)
-  target_link_libraries (glog PUBLIC ${CMAKE_THREAD_LIBS_INIT})
-else (HAVE_PTHREAD)
-  target_compile_definitions (glog PUBLIC NO_THREADS)
-endif (HAVE_PTHREAD)
-
 if (HAVE_EXECINFO_H)
   set (HAVE_STACKTRACE 1)
 endif (HAVE_EXECINFO_H)
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index df7c950..fa9336f 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -32,3 +32,4 @@
 Sergiu Dotenco <sergiu.dotenco@th-nuernberg.de>
 Shinichiro Hamaji <hamaji@google.com>
 tbennun <tbennun@gmail.com>
+Teddy Reed <teddy@prosauce.org>
diff --git a/src/config.h.cmake.in b/src/config.h.cmake.in
index 0094a09..6635df1 100644
--- a/src/config.h.cmake.in
+++ b/src/config.h.cmake.in
@@ -46,6 +46,9 @@
 /* Define to 1 if you have the <memory.h> header file. */
 #cmakedefine HAVE_MEMORY_H
 
+/* define to disable multithreading support. */
+#cmakedefine NO_THREADS
+
 /* define if the compiler implements namespaces */
 #cmakedefine HAVE_NAMESPACES
 
diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in
index d1ac52b..455bd28 100644
--- a/src/glog/logging.h.in
+++ b/src/glog/logging.h.in
@@ -361,6 +361,9 @@
 // default logging directory.
 DECLARE_string(log_dir);
 
+// Set the log file mode.
+DECLARE_int32(logfile_mode);
+
 // Sets the path of the directory into which to put additional links
 // to the log files.
 DECLARE_string(log_link);
diff --git a/src/logging.cc b/src/logging.cc
index 8936fe3..b7c2f4c 100644
--- a/src/logging.cc
+++ b/src/logging.cc
@@ -161,6 +161,8 @@
   return "";
 }
 
+GLOG_DEFINE_int32(logfile_mode, 0664, "Log file mode/permissions.");
+
 GLOG_DEFINE_string(log_dir, DefaultLogDir(),
                    "If specified, logfiles are written into this directory instead "
                    "of the default logging directory.");
@@ -899,7 +901,7 @@
   string string_filename = base_filename_+filename_extension_+
                            time_pid_string;
   const char* filename = string_filename.c_str();
-  int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0664);
+  int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, FLAGS_logfile_mode);
   if (fd == -1) return false;
 #ifdef HAVE_FCNTL
   // Mark the file close-on-exec. We don't really care if this fails