From 3434c4f360af39a97c5f00b8a32d48e96cdf3537 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Thu, 20 Jul 2023 23:03:37 +0200
Subject: [PATCH] Add missing dependency on gmsh for user doc generation

---
 CMakeLists.txt      | 11 ++++++++++-
 README.md           |  7 ++++++-
 cmake/PugsDoc.cmake | 12 +++++++++++-
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d7c731845..93eb3fa00 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -706,6 +706,12 @@ else()
   message(" gnuplot: not found!")
 endif()
 
+if (GMSH)
+  message(" gmsh: ${GMSH}")
+else()
+  message(" gmsh: not found!")
+endif()
+
 if (PYGMENTIZE)
   message(" pygmentize: ${PYGMENTIZE}")
 else()
@@ -718,7 +724,7 @@ else()
   message(" pdflatex: not found!")
 endif()
 
-if (NOT EMACS OR NOT GNUPLOT_FOUND)
+if (NOT EMACS OR NOT GNUPLOT_FOUND OR NOT GMSH)
   message(" ** Cannot build documentation: missing ")
 elseif(NOT LATEX_PDFLATEX_FOUND OR NOT PYGMENTIZE)
   message(" ** Cannot build pdf documentation: missing")
@@ -729,6 +735,9 @@ endif()
 if (NOT GNUPLOT_FOUND)
   message("    - gnuplot")
 endif()
+if (NOT GMSH)
+  message("    - gmsh")
+endif()
 if (NOT LATEX_PDFLATEX_FOUND)
   message("    - pdflatex")
 endif()
diff --git a/README.md b/README.md
index 62d6b4377..36e460a85 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ apt install slepc-dev
 
 ### User documentation
 
-To build documentation one requires `emacs` and `gnuplot`,
+To build documentation one requires `emacs`, `gmsh` and `gnuplot`,
 additionally since examples results are generated, the documentation
 can only be produced after the compilation of `pugs` itself.
 
@@ -94,6 +94,10 @@ To install `emacs` on Debian-like systems
 ```shell
 apt install emacs
 ```
+To install `gmsh` on Debian-like systems
+```shell
+apt install gmsh
+```
 To install `gnuplot` one can either use
 ```shell
 apt install gnuplot-nox
@@ -106,6 +110,7 @@ apt install gnuplot-x11
 > When building the documentation for the first time, a local `emacs`
 > configuration is generated. *This requires an internet connection.*
 
+
 These packages are enough to build the html documentation. To build
 the pdf documentation one requires a few more packages: `pdflatex`
 (actually a fresh texlive installation is probably necessary) and `pygmentize`
diff --git a/cmake/PugsDoc.cmake b/cmake/PugsDoc.cmake
index 1f8701ccc..b067a5cc8 100644
--- a/cmake/PugsDoc.cmake
+++ b/cmake/PugsDoc.cmake
@@ -12,10 +12,13 @@ find_program(PYGMENTIZE pygmentize)
 # check for gnuplot
 find_package(Gnuplot)
 
+# check for gmsh
+find_program(GMSH NAMES gmsh)
+
 add_custom_target(userdoc)
 add_custom_target(doc DEPENDS userdoc)
 
-if (EMACS AND GNUPLOT_FOUND)
+if (EMACS AND GNUPLOT_FOUND AND GMSH)
 
   add_custom_command(
     OUTPUT "${PUGS_BINARY_DIR}/doc"
@@ -129,6 +132,13 @@ else()
       COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red --bold "gnuplot missing")
     add_dependencies(userdoc userdoc-missing-gnuplot)
   endif()
+
+  if (NOT GMSH)
+    add_custom_target(userdoc-missing-gmsh
+      COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --no-newline "Cannot build documentation: "
+      COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red --bold "gmsh missing")
+    add_dependencies(userdoc userdoc-missing-gmsh)
+  endif()
 endif()
 
 add_dependencies(doc userdoc)
-- 
GitLab