Squashed 'third_party/google-glog/' content from commit 5d46e1b

Change-Id: I4d7d0b2759aa01069e6990109ae0f5f9897512c4
git-subtree-dir: third_party/google-glog
git-subtree-split: 5d46e1bcfc92bf06a9ca3b3f1c5bb1dc024d9ecd
diff --git a/cmake/DetermineGflagsNamespace.cmake b/cmake/DetermineGflagsNamespace.cmake
new file mode 100755
index 0000000..3dde42b
--- /dev/null
+++ b/cmake/DetermineGflagsNamespace.cmake
@@ -0,0 +1,69 @@
+macro(determine_gflags_namespace VARIABLE)
+  if (NOT DEFINED "${VARIABLE}")
+    if (CMAKE_REQUIRED_INCLUDES)
+      set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
+    else ()
+      set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS)
+    endif ()
+
+    set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS})
+
+    set(_NAMESPACES gflags google)
+    set(_check_code
+"
+#include <gflags/gflags.h>
+
+int main(int argc, char**argv)
+{
+  GLOG_GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
+}
+")
+    if (NOT CMAKE_REQUIRED_QUIET)
+      message (STATUS "Looking for gflags namespace")
+    endif ()
+    if (${ARGC} EQUAL 3)
+      set (CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
+      set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}")
+    endif ()
+
+    set (_check_file
+        ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/DetermineGflagsNamespace.cxx)
+
+    foreach (_namespace ${_NAMESPACES})
+      file (WRITE "${_check_file}" "${_check_code}")
+      try_compile (${VARIABLE}
+        "${CMAKE_BINARY_DIR}" "${_check_file}"
+        COMPILE_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}" -DGLOG_GFLAGS_NAMESPACE=${_namespace}
+        LINK_LIBRARIES gflags
+        CMAKE_FLAGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+        OUTPUT_VARIABLE OUTPUT)
+
+      if (${VARIABLE})
+        set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace" FORCE)
+        break ()
+      else ()
+        file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+          "Determining the gflags namespace ${_namespace} failed with the following output:\n"
+          "${OUTPUT}\n\n")
+      endif ()
+    endforeach (_namespace)
+
+    if (${ARGC} EQUAL 3)
+      set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE})
+    endif ()
+
+    if (${VARIABLE})
+      if (NOT CMAKE_REQUIRED_QUIET)
+        message (STATUS "Looking for gflags namespace - ${${VARIABLE}}")
+      endif ()
+      file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+        "Determining the gflags namespace passed with the following output:\n"
+        "${OUTPUT}\n\n")
+    else ()
+      if (NOT CMAKE_REQUIRED_QUIET)
+        message (STATUS "Looking for gflags namespace - failed")
+      endif ()
+      set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace")
+    endif ()
+  endif ()
+endmacro ()
diff --git a/cmake/INSTALL.md b/cmake/INSTALL.md
new file mode 100644
index 0000000..a73f05e
--- /dev/null
+++ b/cmake/INSTALL.md
@@ -0,0 +1,81 @@
+# Glog - CMake Support
+
+Glog comes with a CMake build script ([CMakeLists.txt](../CMakeLists.txt)) that can be used on a wide range of platforms.  
+If you don't have CMake installed already, you can download it for free from <http://www.cmake.org/>.
+
+CMake works by generating native makefiles or build projects that can be used in the compiler environment of your choice.  
+You can either build Glog with CMake as a standalone project or it can be incorporated into an existing CMake build for another project.
+
+## Table of Contents
+
+- [Building Glog with CMake](#building-glog-with-cmake)
+- [Consuming Glog in a CMake Project](#consuming-glog-in-a-cmake-project)
+- [Incorporating Glog into a CMake Project](#incorporating-glog-into-a-cmake-project)
+
+## Building Glog with CMake
+
+When building Glog as a standalone project, on Unix-like systems with GNU Make as build tool, the typical workflow is:  
+
+1. Get the source code and change to it.
+e.g. cloning with git:
+```bash
+git clone git@github.com:google/glog.git
+cd glog
+```
+
+2. Run CMake to configure the build tree.
+```bash
+cmake -H. -Bbuild -G "Unix Makefiles"
+```
+note: To get the list of available generators (e.g. Visual Studio), use `-G ""`
+
+3. Afterwards, generated files can be used to compile the project.
+```bash
+cmake --build build
+```
+
+4. Test the build software (optional).
+```bash
+cmake --build build --target test
+```
+
+5. Install the built files (optional).
+```bash
+cmake --build build --target install
+```
+
+## Consuming Glog in a CMake Project
+
+If you have Glog installed in your system, you can use the CMake command
+`find_package()` to include it in your CMake Project.
+
+```cmake
+cmake_minimum_required(VERSION 3.0.2)
+project(myproj VERSION 1.0)
+
+find_package(glog 0.3.5 REQUIRED)
+
+add_executable(myapp main.cpp)
+target_link_libraries(myapp glog::glog)
+```
+
+Compile definitions and options will be added automatically to your target as
+needed.
+
+## Incorporating Glog into a CMake Project
+
+You can also use the CMake command `add_subdirectory()` to include Glog directly from a subdirectory of your project.  
+The **glog::glog** target is in this case an ALIAS library target for the **glog** library target. 
+
+```cmake
+cmake_minimum_required(VERSION 3.0.2)
+project(myproj VERSION 1.0)
+
+add_subdirectory(glog)
+
+add_executable(myapp main.cpp)
+target_link_libraries(myapp glog::glog)
+```
+
+Again, compile definitions and options will be added automatically to your target as
+needed.