From 5ea1ef40792f3fcabda279fa8d44a2181621a7fc Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 11 Feb 2021 20:56:43 +0100
Subject: [PATCH] Replaced SWMMInterface submodule with CPM.

---
 .gitmodules                                |  3 ---
 Applications/FileIO/SWMM/SWMMInterface.cpp |  2 +-
 ThirdParty/CMakeLists.txt                  |  5 -----
 ThirdParty/SwmmInterface                   |  1 -
 scripts/cmake/Dependencies.cmake           | 12 ++++++++++++
 scripts/cmake/SubmoduleSetup.cmake         |  3 ---
 6 files changed, 13 insertions(+), 13 deletions(-)
 delete mode 160000 ThirdParty/SwmmInterface

diff --git a/.gitmodules b/.gitmodules
index 458b19e2cce..6333c7e3825 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
-[submodule "ThirdParty/SwmmInterface"]
-	path = ThirdParty/SwmmInterface
-	url = https://github.com/ufz/SwmmInterface.git
 [submodule "ThirdParty/container-maker"]
 	path = ThirdParty/container-maker
 	url = https://gitlab.opengeosys.org/ogs/container-maker.git
diff --git a/Applications/FileIO/SWMM/SWMMInterface.cpp b/Applications/FileIO/SWMM/SWMMInterface.cpp
index 1251e6b6f45..21492f6a4c0 100644
--- a/Applications/FileIO/SWMM/SWMMInterface.cpp
+++ b/Applications/FileIO/SWMM/SWMMInterface.cpp
@@ -25,7 +25,7 @@
 #include "MeshLib/Mesh.h"
 #include "MeshLib/Node.h"
 #include "MeshLib/Properties.h"
-#include "ThirdParty/SWMMInterface/swmm5_iface.h"
+#include <swmm5_iface.h>
 
 namespace FileIO
 {
diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt
index ac50211fe38..bde2cf76361 100644
--- a/ThirdParty/CMakeLists.txt
+++ b/ThirdParty/CMakeLists.txt
@@ -4,11 +4,6 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VtkFbxConverter/CMakeLists.txt
     add_subdirectory(VtkFbxConverter)
 endif()
 
-if(OGS_BUILD_SWMM)
-    add_subdirectory(SWMMInterface)
-    list(APPEND DISABLE_WARNINGS_TARGETS SWMM SwmmInterface)
-endif()
-
 foreach(TARGET ${DISABLE_WARNINGS_TARGETS})
     target_compile_options(${TARGET} PRIVATE
         $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:-w>
diff --git a/ThirdParty/SwmmInterface b/ThirdParty/SwmmInterface
deleted file mode 160000
index 141e05ae1f4..00000000000
--- a/ThirdParty/SwmmInterface
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 141e05ae1f419918799d7bf9178ebcd97feb1ed3
diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake
index aeedbc60e46..e4c1894650c 100644
--- a/scripts/cmake/Dependencies.cmake
+++ b/scripts/cmake/Dependencies.cmake
@@ -168,6 +168,18 @@ if(OGS_USE_XDMF)
     endif()
 endif()
 
+if(OGS_BUILD_SWMM)
+    CPMAddPackage(
+        NAME SWMMInterface
+        GITHUB_REPOSITORY ufz/SwmmInterface
+        GIT_TAG 141e05ae1f419918799d7bf9178ebcd97feb1ed3
+    )
+    if(SWMMInterface_ADDED)
+        target_include_directories(SwmmInterface SYSTEM PUBLIC ${SWMMInterface_SOURCE_DIR})
+        list(APPEND DISABLE_WARNINGS_TARGETS SWMM SwmmInterface)
+    endif()
+endif()
+
 # Disable warnings
 foreach(TARGET ${DISABLE_WARNINGS_TARGETS})
     target_compile_options(${TARGET} PRIVATE
diff --git a/scripts/cmake/SubmoduleSetup.cmake b/scripts/cmake/SubmoduleSetup.cmake
index 584efe7299b..4ca5a5eb1e1 100644
--- a/scripts/cmake/SubmoduleSetup.cmake
+++ b/scripts/cmake/SubmoduleSetup.cmake
@@ -3,9 +3,6 @@ if(NOT IS_GIT_REPO)
 endif()
 
 # This file initializes the required submodules
-if(OGS_BUILD_SWMM)
-    list(APPEND REQUIRED_SUBMODULES ThirdParty/SwmmInterface)
-endif()
 
 execute_process(
     COMMAND ${GIT_EXECUTABLE} submodule status
-- 
GitLab