From 1bd8098d3d5b7aa8e305e57b2451ab8f98a58965 Mon Sep 17 00:00:00 2001
From: Vitaly Zaitsev <vitaly@easycoding.org>
Date: Wed, 8 Sep 2021 19:40:25 +0200
Subject: [PATCH] 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>
---
CMakeLists.txt | 1 +
src/CMakeLists.txt | 8 +++++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49f2ae2a0..d32dbd83d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,7 @@ else()
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 1df8a4aa8..19ff8857a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -118,7 +118,9 @@ if (BENCHMARK_ENABLE_INSTALL)
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()