Optimized docs installation (#1225)

* Use GNUInstallDirs to install docs.

Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>

* Added an option to disable docs installation.

Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49f2ae2..d32dbd8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,7 @@
   set(BENCHMARK_BUILD_32_BITS OFF CACHE BOOL "Build a 32 bit version of the library - unsupported when using MSVC)" FORCE)
 endif()
 option(BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark. (Projects embedding benchmark may want to turn this OFF.)" ON)
+option(BENCHMARK_INSTALL_DOCS "Enable installation of documentation." ON)
 
 # Allow unmet dependencies to be met using CMake's ExternalProject mechanics, which
 # may require downloading the source code.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1df8a4a..19ff885 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -118,7 +118,9 @@
       NAMESPACE "${namespace}"
       DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
 
-  install(
-    DIRECTORY "${PROJECT_SOURCE_DIR}/docs/"
-    DESTINATION "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
+  if (BENCHMARK_INSTALL_DOCS)
+    install(
+      DIRECTORY "${PROJECT_SOURCE_DIR}/docs/"
+      DESTINATION "${CMAKE_INSTALL_DOCDIR}")
+  endif()
 endif()