From 8a563f7b0e2faabcb1a5b05e7a132f68a81b4af9 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Mon, 8 Mar 2021 14:48:22 +0100
Subject: [PATCH] [cpm] Suppress tests from dependencies.

---
 scripts/cmake/Dependencies.cmake        |  7 +++++--
 scripts/cmake/test/CTestCustom.in.cmake | 12 ++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
 create mode 100644 scripts/cmake/test/CTestCustom.in.cmake

diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake
index 3d40eb28922..7cc8199dab1 100644
--- a/scripts/cmake/Dependencies.cmake
+++ b/scripts/cmake/Dependencies.cmake
@@ -118,7 +118,6 @@ if(OGS_USE_MFRONT)
         OPTIONS
             "enable-doxygen-doc OFF"
             "enable-fortran-bindings OFF"
-            "BUILD_TESTING OFF"
         EXCLUDE_FROM_ALL YES
     )
     if(MGIS_ADDED)
@@ -154,7 +153,6 @@ if(OGS_USE_XDMF)
         OPTIONS
             "HDF5_EXTERNALLY_CONFIGURED 1"
             "HDF5_GENERATE_HEADERS OFF"
-            "BUILD_TESTING OFF"
             "HDF5_BUILD_TOOLS OFF"
             "HDF5_BUILD_EXAMPLES OFF"
             "HDF5_BUILD_HL_LIB OFF"
@@ -304,3 +302,8 @@ foreach(TARGET ${DISABLE_WARNINGS_TARGETS})
         $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:-w>
         $<$<CXX_COMPILER_ID:MSVC>:/W0>)
 endforeach()
+
+# Hack: Disable tests from dependencies
+configure_file(${PROJECT_SOURCE_DIR}/scripts/cmake/test/CTestCustom.in.cmake
+    ${PROJECT_BINARY_DIR}/CTestCustom.cmake @ONLY
+)
diff --git a/scripts/cmake/test/CTestCustom.in.cmake b/scripts/cmake/test/CTestCustom.in.cmake
new file mode 100644
index 00000000000..5f401e4561a
--- /dev/null
+++ b/scripts/cmake/test/CTestCustom.in.cmake
@@ -0,0 +1,12 @@
+file (STRINGS "@PROJECT_BINARY_DIR@/CTestTestfile.cmake" LINES)
+
+# overwrite the file....
+file(WRITE "@PROJECT_BINARY_DIR@/CTestTestfile.cmake" "")
+
+# loop through the lines,
+foreach(LINE IN LISTS LINES)
+  # remove unwanted parts
+  string(REGEX REPLACE ".*_deps/.*" "" STRIPPED "${LINE}")
+  # and write the (changed) line ...
+  file(APPEND "@PROJECT_BINARY_DIR@/CTestTestfile.cmake" "${STRIPPED}\n")
+endforeach()
-- 
GitLab