From 9be2fe439e18b3d00b819c52f060c30b79ad4e9e Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 29 Oct 2024 11:40:29 +0100
Subject: [PATCH] [cmake] Simplified ProcessLib setup.

---
 ProcessLib/CMakeLists.txt | 59 +++++++++++++--------------------------
 1 file changed, 20 insertions(+), 39 deletions(-)

diff --git a/ProcessLib/CMakeLists.txt b/ProcessLib/CMakeLists.txt
index 134c385e635..014271adde7 100644
--- a/ProcessLib/CMakeLists.txt
+++ b/ProcessLib/CMakeLists.txt
@@ -2,27 +2,17 @@
 add_library(Processes INTERFACE)
 
 # Check whether LIE processes are enabled
-function(check_enabled_processes_for_LIE contains_LIE)
-    set(${contains_hm_process} FALSE PARENT_SCOPE)
-    foreach(process ${_enabled_processes})
-        if(process STREQUAL "LIE_M"
-           OR process STREQUAL "LIE_HM"
-        )
-            set(${contains_LIE} TRUE PARENT_SCOPE)
-            return()
-        endif()
-    endforeach()
-endfunction()
-check_enabled_processes_for_LIE(contains_LIE)
-
-if (contains_LIE)
-    add_subdirectory(LIE/Common)
-endif()
+foreach(process ${_enabled_processes})
+    if(process STREQUAL "LIE_M" OR process STREQUAL "LIE_HM")
+        add_subdirectory(LIE/Common)
+        break()
+    endif()
+endforeach()
 
 foreach(process ${_enabled_processes})
-    if (process STREQUAL "LIE_HM")
+    if(process STREQUAL "LIE_HM")
         add_subdirectory(LIE/HydroMechanics)
-    elseif (process STREQUAL "LIE_M")
+    elseif(process STREQUAL "LIE_M")
         add_subdirectory(LIE/SmallDeformation)
     else()
         add_subdirectory(${process})
@@ -43,27 +33,18 @@ append_source_files(SOURCES Utils)
 append_source_files(SOURCES Reflection)
 append_source_files(SOURCES Graph)
 # For processes that contains both hydraulical process and mechanical process
-# Define a function to check if enabled_processes contains LIE, HydroMechanics,
-# ThermoHydroMechanics, RichardsMechanics, or ThermoRichardsMechanics
-function(check_enabled_processes contains_hm_process)
-    set(${contains_hm_process} FALSE PARENT_SCOPE)
-    foreach(process ${_enabled_processes})
-        if(process STREQUAL "LIE_HM"
-           OR process STREQUAL "HydroMechanics"
-           OR process STREQUAL "ThermoHydroMechanics"
-           OR process STREQUAL "RichardsMechanics"
-           OR process STREQUAL "TH2M"
-           OR process STREQUAL "ThermoRichardsMechanics"
-        )
-            set(${contains_hm_process} TRUE PARENT_SCOPE)
-            return()
-        endif()
-    endforeach()
-endfunction()
-check_enabled_processes(contains_hm_process)
-if(contains_hm_process)
-    append_source_files(SOURCES Common/HydroMechanics)
-endif()
+foreach(process ${_enabled_processes})
+    if(process STREQUAL "LIE_HM"
+       OR process STREQUAL "HydroMechanics"
+       OR process STREQUAL "ThermoHydroMechanics"
+       OR process STREQUAL "RichardsMechanics"
+       OR process STREQUAL "TH2M"
+       OR process STREQUAL "ThermoRichardsMechanics"
+    )
+        append_source_files(SOURCES Common/HydroMechanics)
+        break()
+    endif()
+endforeach()
 
 ogs_add_library(ProcessLib GENERATE_EXPORT_HEADER ${SOURCES})
 
-- 
GitLab