From 236185afb7d225f453f29b0245643400e27ca2e9 Mon Sep 17 00:00:00 2001
From: Brent Huisman <brenthuisman@users.noreply.github.com>
Date: Mon, 7 Dec 2020 17:21:34 +0100
Subject: [PATCH] Use FindPythonModule to warn for missing svgwrite (#1243)

Update CMake configure to look for svgwrite when building docs.

Fixes #1128.
---
 doc/CMakeLists.txt | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index d90dcb80..1b3f23f5 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1,9 +1,17 @@
+include(FindPythonModule) # required for find_python_module
+
 find_package(Sphinx)
 add_target_if(SPHINX_FOUND
     check-sphinx
     "Finding Sphinx"
     "Sphinx must be installed to build documentation")
 
+find_python_module(svgwrite)
+add_target_if(HAVE_SVGWRITE
+    ext-svgwrite
+    "Finding svgwrite"
+    "The Python module svgwrite needs to be installed to build documentation. Use pip to install svgwrite")
+
 set(html_dir "${CMAKE_CURRENT_BINARY_DIR}/html")
 set(doctree_dir "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
 
@@ -19,7 +27,7 @@ add_custom_target(html
         -q                          # Quiet: no output other than errors and warnings.
         ${CMAKE_CURRENT_SOURCE_DIR} # Source directory
         ${html_dir}                 # Output directory
-    DEPENDS check-sphinx ext-sphinx_rtd_theme
+    DEPENDS check-sphinx ext-sphinx_rtd_theme ext-svgwrite
     COMMENT
         "Generating Sphinx documentation")
 
-- 
GitLab