From 377fafe2f70a1e137cea35b92332394070401f8f Mon Sep 17 00:00:00 2001
From: Rainer Kartmann <rainer.kartmann@kit.edu>
Date: Fri, 17 Mar 2023 17:18:13 +0100
Subject: [PATCH] Fix recursively listing directories for documentation

---
 CMakeModules/SimoxMacros.cmake | 33 ++++++++++++++++++++++++++-------
 doc/CMakeLists.txt             |  5 ++---
 2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/CMakeModules/SimoxMacros.cmake b/CMakeModules/SimoxMacros.cmake
index c5a1d42aa..6833235eb 100644
--- a/CMakeModules/SimoxMacros.cmake
+++ b/CMakeModules/SimoxMacros.cmake
@@ -54,15 +54,34 @@ function(SimoxQtLibrary name srcs incs mocFiles uiFiles)
     TARGET_LINK_LIBRARIES(${name} PUBLIC GraspStudio Saba)
 endfunction()
 
-macro(simox_subdirs result curdir)
-    file(GLOB children ${curdir}/*)
-    set(${result})
-    foreach(child ${children})
-        if(IS_DIRECTORY ${child})
-            list(APPEND ${result} ${child})
+function(simox_subdirs RESULT DIRECTORY)
+    file(GLOB CHILDREN ${DIRECTORY}/*)
+    # message("## children of ${DIRECTORY}: ${CHILDREN}")
+
+    set(DIR_CHILDREN "")
+    foreach(CHILD ${CHILDREN})
+        if (IS_DIRECTORY "${CHILD}")
+            list(APPEND DIR_CHILDREN ${CHILD})
         endif()
     endforeach()
-endmacro()
+
+    set(${RESULT} "${DIR_CHILDREN}" PARENT_SCOPE)
+endfunction()
+
+
+function(simox_subdirs_recursive RESULT DIRECTORY)
+    simox_subdirs(TOP_CHILDREN "${DIRECTORY}")
+    set(ALL_CHILDREN ${TOP_CHILDREN})
+
+    foreach(TOP_CHILD ${TOP_CHILDREN})
+        simox_subdirs_recursive(REC_CHILDREN ${TOP_CHILD})
+        list(APPEND ALL_CHILDREN ${REC_CHILDREN})
+    endforeach()
+
+    set(${RESULT} "${ALL_CHILDREN}" PARENT_SCOPE)
+
+endfunction()
+
 
 macro(simox_update_file file content) #macro since we want to provide simox_file_up_to_date
     set(simox_file_up_to_date 0)
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 3a0695752..907d79aa8 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -35,9 +35,8 @@ IF(DOXYGEN_FOUND)
         "${CMAKE_CURRENT_SOURCE_DIR}/../SimoxQtUtility"
     )
 
-    simox_subdirs(SIMOX_SUBDIRS "${CMAKE_CURRENT_SOURCE_DIR}/../SimoxUtility")
-    SET (CMAKE_DOXYGEN_INPUT_LIST  ${CMAKE_DOXYGEN_INPUT_LIST}
-        ${SIMOX_SUBDIRS})
+    simox_subdirs_recursive(SIMOX_UTILITY_SUBDIRS "${CMAKE_CURRENT_SOURCE_DIR}/../SimoxUtility")
+    LIST (APPEND CMAKE_DOXYGEN_INPUT_LIST ${SIMOX_UTILITY_SUBDIRS})
 
     # consider visualization setup
     IF (Simox_USE_COIN_VISUALIZATION)
-- 
GitLab