From 529a2b1f92c2343ea2295bf27f6a00d56ef2978a Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 20 Sep 2016 17:12:15 +0200
Subject: [PATCH] [CMake] Introduced CMake option OGS_BUILD_METIS.

---
 Applications/Utils/CMakeLists.txt                  | 8 +-------
 Applications/Utils/ModelPreparation/CMakeLists.txt | 4 ++++
 CMakeLists.txt                                     | 2 ++
 ThirdParty/CMakeLists.txt                          | 2 +-
 scripts/cmake/SubmoduleSetup.cmake                 | 2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Applications/Utils/CMakeLists.txt b/Applications/Utils/CMakeLists.txt
index f860ed1f94c..33dec83449b 100644
--- a/Applications/Utils/CMakeLists.txt
+++ b/Applications/Utils/CMakeLists.txt
@@ -7,13 +7,7 @@ add_subdirectory(SimpleMeshCreation)
 
 if(OGS_BUILD_GUI)
     add_subdirectory(OGSFileConverter)
-else()
-    # When OGS_BUILD_GUI=ON, vtk libraries are linked to every object in
-    # building, which lets the compilation of mpmetis (in the project
-    # of PartitionMesh) fail. Therefore, the following subdirectory is
-    # excluded when OGS_BUILD_GUI=ON.
-    add_subdirectory(ModelPreparation/PartitionMesh)
-endif() # OGS_BUILD_GUI
+endif()
 
 if(OGS_BUILD_SWMM)
     add_subdirectory(SWMMConverter)
diff --git a/Applications/Utils/ModelPreparation/CMakeLists.txt b/Applications/Utils/ModelPreparation/CMakeLists.txt
index 0d04e3a8a72..c90970e913a 100644
--- a/Applications/Utils/ModelPreparation/CMakeLists.txt
+++ b/Applications/Utils/ModelPreparation/CMakeLists.txt
@@ -18,3 +18,7 @@ target_link_libraries(createNeumannBc
     MeshLib
     ${OGS_VTK_REQUIRED_LIBS}
 )
+
+if(OGS_BUILD_METIS)
+    add_subdirectory(PartitionMesh)
+endif()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e09179da6f..1b9149bd088 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,6 +66,8 @@ if(NOT WIN32 AND OGS_BUILD_SWMM)
     message(FATAL_ERROR "OGS_BUILD_SWMM requires Windows!")
 endif()
 
+option(OGS_BUILD_METIS "Should metis and the partmesh util be built?" OFF)
+
 option(OGS_NO_EXTERNAL_LIBS "Builds OGS without any external dependencies." OFF)
 
 # Linear solvers
diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt
index e28dae35126..9ce23dbd69d 100644
--- a/ThirdParty/CMakeLists.txt
+++ b/ThirdParty/CMakeLists.txt
@@ -55,6 +55,6 @@ if(OGS_BUILD_SWMM)
     add_subdirectory(${CMAKE_SOURCE_DIR}/ThirdParty/SWMMInterface)
 endif()
 
-if(OGS_BUILD_UTILS)
+if(OGS_BUILD_METIS)
     include(${CMAKE_SOURCE_DIR}/scripts/cmake/MetisSetup.cmake)
 endif()
diff --git a/scripts/cmake/SubmoduleSetup.cmake b/scripts/cmake/SubmoduleSetup.cmake
index ed365649630..8f0fab35f78 100644
--- a/scripts/cmake/SubmoduleSetup.cmake
+++ b/scripts/cmake/SubmoduleSetup.cmake
@@ -18,7 +18,7 @@ endif()
 if(OGS_BUILD_GUI)
     list(APPEND REQUIRED_SUBMODULES ThirdParty/vtkGUISupportQt)
 endif()
-if(OGS_BUILD_UTILS)
+if(OGS_BUILD_METIS)
     list(APPEND REQUIRED_SUBMODULES ThirdParty/metis)
 endif()
 if(OGS_BUILD_SWMM)
-- 
GitLab