From 5b7bb2514eabd5128916a1c9a85428d98c214691 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Fri, 14 Dec 2018 16:16:20 +0100
Subject: [PATCH] refactor(doc): Enable only if sphinx is available
---
CMakeLists.txt | 4 +++-
cmake/02-opts.cmake | 3 ++-
doc/CMakeLists.txt | 14 +++++++++-----
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a18aeff8..82922100 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,7 +58,9 @@ include(03-libs)
include(04-targets)
include(05-summary)
-add_subdirectory(doc)
+if(BUILD_DOC)
+ add_subdirectory(doc)
+endif()
add_subdirectory(doc/bash)
add_subdirectory(doc/zsh)
add_subdirectory(include)
diff --git a/cmake/02-opts.cmake b/cmake/02-opts.cmake
index 65cae7e3..6b271e24 100644
--- a/cmake/02-opts.cmake
+++ b/cmake/02-opts.cmake
@@ -1,6 +1,7 @@
#
# Build options
#
+checklib(BUILD_DOC "binary" sphinx-build)
checklib(ENABLE_ALSA "pkg-config" alsa)
checklib(ENABLE_CURL "pkg-config" libcurl)
@@ -30,7 +31,7 @@ option(CXXLIB_GCC "Link against stdlibc++" OFF)
option(BUILD_IPC_MSG "Build ipc messager" ON)
option(BUILD_TESTS "Build testsuite" OFF)
-option(BUILD_TESTS "Build documentation" ON)
+option(BUILD_DOC "Build documentation" ON)
option(ENABLE_ALSA "Enable alsa support" ON)
option(ENABLE_CURL "Enable curl support" ON)
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index d5105d62..65b8a0ef 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(NOT BUILD_DOC)
- return()
-endif()
-
#
# Generate configuration file
#
@@ -98,6 +94,14 @@ install(FILES config
# }}}
# Documentation {{{
+find_program(SPHINX_EXECUTABLE
+ NAMES sphinx-build
+ DOC "Sphinx Documentation Builder")
+
+if(NOT SPHINX_EXECUTABLE)
+ message_colored(FATAL_ERROR "Failed to locate sphinx-build" 31)
+endif()
+
configure_file(conf.py.in conf.py @ONLY)
set(SPHINX_FLAGS "" CACHE STRING "Flags to pass to sphinx-build")
@@ -115,7 +119,7 @@ foreach(builder ${doc_builders})
set(doc_target "doc_${builder}")
set(builder_log "builder-${builder}.log")
add_custom_target(${doc_target}
- COMMAND sphinx-build
+ COMMAND ${SPHINX_EXECUTABLE}
-b ${builder}
-c "${CMAKE_CURRENT_BINARY_DIR}"
-d "${CMAKE_CURRENT_BINARY_DIR}/doctrees"