From 31e044349765bc78a6550cd448d78beb90bd85eb Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Mon, 8 Feb 2021 21:10:37 +0100
Subject: [PATCH] Replaced tclap submodule with CPM.

---
 .gitmodules                                          |  3 ---
 Applications/CLI/CMakeLists.txt                      |  1 +
 Applications/Utils/FileConverter/CMakeLists.txt      |  2 +-
 Applications/Utils/GeoTools/CMakeLists.txt           |  1 +
 Applications/Utils/MeshEdit/CMakeLists.txt           |  4 ++--
 Applications/Utils/MeshGeoTools/CMakeLists.txt       |  4 +++-
 Applications/Utils/ModelPreparation/CMakeLists.txt   |  2 +-
 .../ModelPreparation/PartitionMesh/CMakeLists.txt    |  2 +-
 Applications/Utils/OGSFileConverter/CMakeLists.txt   |  2 +-
 Applications/Utils/PostProcessing/CMakeLists.txt     |  4 ++--
 Applications/Utils/SWMMConverter/CMakeLists.txt      |  4 +++-
 Applications/Utils/SimpleMeshCreation/CMakeLists.txt |  2 +-
 CMakeLists.txt                                       |  1 -
 Tests/xdmfdiff/CMakeLists.txt                        |  2 +-
 ThirdParty/tclap                                     |  1 -
 scripts/cmake/Find.cmake                             | 12 +++++++++++-
 scripts/cmake/SubmoduleSetup.cmake                   |  1 -
 17 files changed, 29 insertions(+), 19 deletions(-)
 delete mode 160000 ThirdParty/tclap

diff --git a/.gitmodules b/.gitmodules
index 7ea8d46e61d..a3e069e3f64 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,9 +4,6 @@
 [submodule "vtkdiff"]
 	path = ThirdParty/vtkdiff
 	url = https://github.com/ufz/vtkdiff.git
-[submodule "ThirdParty/tclap"]
-	path = ThirdParty/tclap
-	url = https://github.com/ufz/tclap.git
 [submodule "ThirdParty/metis"]
 	path = ThirdParty/metis
 	url = https://github.com/scibuilder/metis.git
diff --git a/Applications/CLI/CMakeLists.txt b/Applications/CLI/CMakeLists.txt
index 494c0255a65..a8eb184cc7d 100644
--- a/Applications/CLI/CMakeLists.txt
+++ b/Applications/CLI/CMakeLists.txt
@@ -59,6 +59,7 @@ target_link_libraries(ogs
         $<$<TARGET_EXISTS:ogs_embedded_python>:ogs_embedded_python>
         $<$<TARGET_EXISTS:MPI::MPI_CXX>:MPI::MPI_CXX>
         $<$<TARGET_EXISTS:InSituLib>:InSituLib>
+        tclap
 )
 
 target_compile_definitions(ogs
diff --git a/Applications/Utils/FileConverter/CMakeLists.txt b/Applications/Utils/FileConverter/CMakeLists.txt
index 26e2ccaffe9..a18a9718c2c 100644
--- a/Applications/Utils/FileConverter/CMakeLists.txt
+++ b/Applications/Utils/FileConverter/CMakeLists.txt
@@ -28,7 +28,7 @@ endif()
 
 foreach(TOOL ${TOOLS})
     add_executable(${TOOL} ${TOOL}.cpp)
-    target_link_libraries(${TOOL} ApplicationsFileIO GitInfoLib MeshLib)
+    target_link_libraries(${TOOL} ApplicationsFileIO GitInfoLib MeshLib tclap)
 endforeach()
 set_target_properties(${TOOLS} PROPERTIES FOLDER Utilities)
 install(TARGETS ${TOOLS} RUNTIME DESTINATION bin COMPONENT Utilities)
diff --git a/Applications/Utils/GeoTools/CMakeLists.txt b/Applications/Utils/GeoTools/CMakeLists.txt
index d925823fca5..efa9100d7ef 100644
--- a/Applications/Utils/GeoTools/CMakeLists.txt
+++ b/Applications/Utils/GeoTools/CMakeLists.txt
@@ -9,6 +9,7 @@ foreach(TOOL ${TOOLS})
                           GeoLib
                           GitInfoLib
                           ApplicationsFileIO
+                          tclap
                           Qt5::Core)
 endforeach()
 set_target_properties(${TOOLS} PROPERTIES FOLDER Utilities)
diff --git a/Applications/Utils/MeshEdit/CMakeLists.txt b/Applications/Utils/MeshEdit/CMakeLists.txt
index 7e6ab0849ea..45322b4a65c 100644
--- a/Applications/Utils/MeshEdit/CMakeLists.txt
+++ b/Applications/Utils/MeshEdit/CMakeLists.txt
@@ -30,14 +30,14 @@ if(OGS_BUILD_GUI)
         ${PROJECT_SOURCE_DIR}/ThirdParty/paraview/vtkCleanUnstructuredGrid.cpp)
     target_include_directories(RemoveGhostData
         PRIVATE ${PROJECT_SOURCE_DIR}/ThirdParty/paraview)
-    target_link_libraries(RemoveGhostData GitInfoLib MeshLib)
+    target_link_libraries(RemoveGhostData GitInfoLib MeshLib tclap)
     set_target_properties(RemoveGhostData PROPERTIES FOLDER Utilities)
     install(TARGETS RemoveGhostData RUNTIME DESTINATION bin COMPONENT Utilities)
 endif()
 
 foreach(TOOL ${TOOLS})
     add_executable(${TOOL} ${TOOL}.cpp)
-    target_link_libraries(${TOOL} GitInfoLib MeshLib)
+    target_link_libraries(${TOOL} GitInfoLib MeshLib tclap)
 endforeach()
 set_target_properties(${TOOLS} PROPERTIES FOLDER Utilities)
 install(TARGETS ${TOOLS} RUNTIME DESTINATION bin COMPONENT Utilities)
diff --git a/Applications/Utils/MeshGeoTools/CMakeLists.txt b/Applications/Utils/MeshGeoTools/CMakeLists.txt
index fbe634be3d0..324e80d8fdb 100644
--- a/Applications/Utils/MeshGeoTools/CMakeLists.txt
+++ b/Applications/Utils/MeshGeoTools/CMakeLists.txt
@@ -20,7 +20,9 @@ foreach(TOOL ${TOOLS})
                           ApplicationsFileIO
                           GitInfoLib
                           MeshLib
-                          MeshGeoToolsLib)
+                          MeshGeoToolsLib
+                          tclap
+    )
 endforeach()
 
 if(TARGET VerticalSliceFromLayers)
diff --git a/Applications/Utils/ModelPreparation/CMakeLists.txt b/Applications/Utils/ModelPreparation/CMakeLists.txt
index 683b6ebf448..dea0a6c8b16 100644
--- a/Applications/Utils/ModelPreparation/CMakeLists.txt
+++ b/Applications/Utils/ModelPreparation/CMakeLists.txt
@@ -2,7 +2,7 @@ set(TOOLS ComputeNodeAreasFromSurfaceMesh convertVtkDataArrayToVtkDataArray
           createNeumannBc scaleProperty)
 foreach(TOOL ${TOOLS})
     add_executable(${TOOL} ${TOOL}.cpp)
-    target_link_libraries(${TOOL} GitInfoLib MeshLib)
+    target_link_libraries(${TOOL} GitInfoLib MeshLib tclap)
 endforeach()
 set_target_properties(${TOOLS} PROPERTIES FOLDER Utilities)
 install(TARGETS ${TOOLS} RUNTIME DESTINATION bin COMPONENT Utilities)
diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt b/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt
index 44b852e052c..26815713ce4 100644
--- a/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt
+++ b/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_executable(partmesh PartitionMesh.cpp Metis.cpp NodeWiseMeshPartitioner.cpp)
 set_target_properties(partmesh PROPERTIES FOLDER Utilities)
-target_link_libraries(partmesh GitInfoLib MeshLib)
+target_link_libraries(partmesh GitInfoLib MeshLib tclap)
 add_dependencies(partmesh mpmetis)
 install(TARGETS partmesh RUNTIME DESTINATION bin COMPONENT ogs_partmesh)
diff --git a/Applications/Utils/OGSFileConverter/CMakeLists.txt b/Applications/Utils/OGSFileConverter/CMakeLists.txt
index e7ead14d312..df1df12b7dd 100644
--- a/Applications/Utils/OGSFileConverter/CMakeLists.txt
+++ b/Applications/Utils/OGSFileConverter/CMakeLists.txt
@@ -9,7 +9,7 @@ set_target_properties(OGSFileConverterLib PROPERTIES AUTOMOC TRUE AUTOUIC TRUE)
 add_executable(OGSFileConverter main.cpp)
 
 target_link_libraries(OGSFileConverter
-                      PUBLIC ApplicationsFileIO GitInfoLib OGSFileConverterLib)
+                      PUBLIC ApplicationsFileIO GitInfoLib OGSFileConverterLib tclap)
 
 add_autogen_include(OGSFileConverterLib)
 
diff --git a/Applications/Utils/PostProcessing/CMakeLists.txt b/Applications/Utils/PostProcessing/CMakeLists.txt
index 68b8de91944..56d7df38bd1 100644
--- a/Applications/Utils/PostProcessing/CMakeLists.txt
+++ b/Applications/Utils/PostProcessing/CMakeLists.txt
@@ -1,13 +1,13 @@
 if(OGS_BUILD_PROCESS_LIE)
     add_executable(postLIE postLIE.cpp)
-    target_link_libraries(postLIE GitInfoLib LIECommon)
+    target_link_libraries(postLIE GitInfoLib LIECommon tclap)
     set_target_properties(postLIE PROPERTIES FOLDER Utilities)
     install(TARGETS postLIE RUNTIME DESTINATION bin COMPONENT Utilities)
 endif()
 
 if(OGS_BUILD_GUI)
     add_executable(Raster2PointCloud Raster2PointCloud.cpp)
-    target_link_libraries(Raster2PointCloud GitInfoLib ApplicationsFileIO BaseLib GeoLib VtkVis QtDataView)
+    target_link_libraries(Raster2PointCloud GitInfoLib ApplicationsFileIO BaseLib GeoLib VtkVis QtDataView tclap)
     set_target_properties(Raster2PointCloud PROPERTIES FOLDER Utilities)
     install(TARGETS Raster2PointCloud RUNTIME DESTINATION bin COMPONENT Utilities)
 endif()
diff --git a/Applications/Utils/SWMMConverter/CMakeLists.txt b/Applications/Utils/SWMMConverter/CMakeLists.txt
index 77f9e68a993..ba04ef30831 100644
--- a/Applications/Utils/SWMMConverter/CMakeLists.txt
+++ b/Applications/Utils/SWMMConverter/CMakeLists.txt
@@ -4,7 +4,9 @@ target_link_libraries(SWMMConverter
                       GeoLib
                       GitInfoLib
                       MeshLib
-                      SwmmInterface)
+                      SwmmInterface
+                      tclap
+)
 include_directories(${PROJECT_SOURCE_DIR}/Applications/FileIO)
 set_target_properties(SWMMConverter PROPERTIES FOLDER Utilities)
 install(TARGETS SWMMConverter RUNTIME DESTINATION bin COMPONENT Utilities)
diff --git a/Applications/Utils/SimpleMeshCreation/CMakeLists.txt b/Applications/Utils/SimpleMeshCreation/CMakeLists.txt
index ebef70b4a16..b75f2d0e41d 100644
--- a/Applications/Utils/SimpleMeshCreation/CMakeLists.txt
+++ b/Applications/Utils/SimpleMeshCreation/CMakeLists.txt
@@ -5,7 +5,7 @@ endif()
 
 foreach(TOOL ${TOOLS})
     add_executable(${TOOL} ${TOOL}.cpp)
-    target_link_libraries(${TOOL} ApplicationsFileIO GitInfoLib MeshLib)
+    target_link_libraries(${TOOL} ApplicationsFileIO GitInfoLib MeshLib tclap)
 endforeach()
 set_target_properties(${TOOLS} PROPERTIES FOLDER Utilities)
 install(TARGETS ${TOOLS} RUNTIME DESTINATION bin COMPONENT Utilities)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 44c7796bc87..72503191ce9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -223,7 +223,6 @@ add_subdirectory(ThirdParty)
 include_directories(
     SYSTEM
     ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty
-    ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/tclap/include
     ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/json/include
 )
 
diff --git a/Tests/xdmfdiff/CMakeLists.txt b/Tests/xdmfdiff/CMakeLists.txt
index 65e64bf69f6..267a0d71306 100644
--- a/Tests/xdmfdiff/CMakeLists.txt
+++ b/Tests/xdmfdiff/CMakeLists.txt
@@ -1,3 +1,3 @@
 add_executable(xdmfdiff xdmfdiff.cpp)
-target_link_libraries(xdmfdiff OgsXdmf std::filesystem)
+target_link_libraries(xdmfdiff OgsXdmf std::filesystem tclap)
 install(PROGRAMS $<TARGET_FILE:xdmfdiff> DESTINATION bin COMPONENT ogs_extras)
diff --git a/ThirdParty/tclap b/ThirdParty/tclap
deleted file mode 160000
index 03abc3a3327..00000000000
--- a/ThirdParty/tclap
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 03abc3a3327214137c6ffd5b9a6efe23f0927cc2
diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake
index 7cd90c940eb..a1cd935fa30 100644
--- a/scripts/cmake/Find.cmake
+++ b/scripts/cmake/Find.cmake
@@ -36,9 +36,19 @@ CPMAddPackage(
     NAME spdlog
     GITHUB_REPOSITORY gabime/spdlog
     VERSION 1.8.2
-    # DOWNLOAD_ONLY YES
 )
 
+CPMAddPackage(
+    NAME tclap
+    GITHUB_REPOSITORY ufz/tclap
+    GIT_TAG 03abc3a3327214137c6ffd5b9a6efe23f0927cc2
+    DOWNLOAD_ONLY YES
+)
+if(tclap_ADDED)
+    add_library(tclap INTERFACE IMPORTED)
+    target_include_directories(tclap INTERFACE ${tclap_SOURCE_DIR}/include)
+endif()
+
 ######################
 ### Find tools     ###
 ######################
diff --git a/scripts/cmake/SubmoduleSetup.cmake b/scripts/cmake/SubmoduleSetup.cmake
index 1f0580bf2e7..dbfa1f68185 100644
--- a/scripts/cmake/SubmoduleSetup.cmake
+++ b/scripts/cmake/SubmoduleSetup.cmake
@@ -12,7 +12,6 @@ set(REQUIRED_SUBMODULES
     ThirdParty/cmake-modules
     ThirdParty/iphreeqc/src
     ThirdParty/json-cmake
-    ThirdParty/tclap
     ThirdParty/tetgen
     ${OGS_ADDITIONAL_SUBMODULES_TO_CHECKOUT}
 )
-- 
GitLab