From 91e0386faa9e04c0695a90d324cf68a459a362fb Mon Sep 17 00:00:00 2001
From: AlQuemist <alquemist@Lyriks>
Date: Wed, 14 Aug 2024 14:40:42 +0200
Subject: [PATCH] rawEx/CMakeLists.txt: produce examples for the 'figures'
 target

Adapted also 'publicmode.erb' and 'testmode.erb' files.
---
 rawEx/CMakeLists.txt | 14 ++++++++++++++
 rawEx/publicmode.erb |  2 +-
 rawEx/testmode.erb   |  2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/rawEx/CMakeLists.txt b/rawEx/CMakeLists.txt
index e1cfe91902f..b30a37b767e 100644
--- a/rawEx/CMakeLists.txt
+++ b/rawEx/CMakeLists.txt
@@ -34,6 +34,20 @@ foreach(ex ${examples})
     )
     list(APPEND outputs ${ex_out})
     # message(STATUS "ADD ${ex_out}")
+
+    # configure the version of examples to produce documentation figures
+    string(REPLACE ${EXAMPLES_SRC_DIR} ${EXAMPLES_FIGURES_DIR} out_path ${in_path})
+    file(MAKE_DIRECTORY ${out_path})
+    set(ex_out ${out_path}/${ex_name})
+    add_custom_command(
+        OUTPUT ${ex_out}
+        COMMAND erb -T - ${CMAKE_CURRENT_SOURCE_DIR}/figuremode.erb ${ex} > ${ex_out}
+        COMMAND chmod a+x ${ex_out}
+        DEPENDS ${ex}
+    )
+    list(APPEND outputs ${ex_out})
+    # message(STATUS "ADD ${ex_out}")
+
 endforeach()
 
 add_custom_target(configured_examples ALL DEPENDS ${outputs})
diff --git a/rawEx/publicmode.erb b/rawEx/publicmode.erb
index 1e4cde5f5db..fd2f21155d2 100644
--- a/rawEx/publicmode.erb
+++ b/rawEx/publicmode.erb
@@ -1 +1 @@
-<% test_mode = false; -%>
+<% test_mode = false; figure_mode = false; -%>
diff --git a/rawEx/testmode.erb b/rawEx/testmode.erb
index ef708755928..55062df65d4 100644
--- a/rawEx/testmode.erb
+++ b/rawEx/testmode.erb
@@ -1 +1 @@
-<% test_mode = true; -%>
+<% test_mode = true; figure_mode = false; -%>
-- 
GitLab