From 602587d9651d4c346036bcaac99be2e8ad23ed7d Mon Sep 17 00:00:00 2001
From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be>
Date: Tue, 31 Mar 2015 11:36:02 +0000
Subject: [PATCH] cmake (gmsh) : add an option to disable ctest (so that I can
 use ctest in dg and still include gmsh CMakeList.txt)

---
 CMakeLists.txt | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 79618cc62b..0c12fe55f6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1760,24 +1760,27 @@ endif(ENABLE_WRAP_JAVA)
 
 include(CPack)
 
-include(CTest)
-file(GLOB_RECURSE TESTFILES 
-     tutorial/*.geo demos/*.geo benchmarks/?d/*.geo benchmarks/extrude/*.geo)
-foreach(TESTFILE ${TESTFILES})
-  # use relative path for cygwin/mingw (the pure win exe built with the mingw 
-  # compilers does not understand a full cygwin-style path)
-  FILE(RELATIVE_PATH TEST ${CMAKE_CURRENT_BINARY_DIR} ${TESTFILE})
-  add_test(${TEST} ./gmsh ${TEST} -3 -nopopup -o ./tmp.msh)
-endforeach()
-# if(HAVE_PYTHON)
-#   file(GLOB_RECURSE TESTFILES tutorial/*.py)
-#   foreach(TESTFILE ${TESTFILES})
-#     add_test(NAME ${TESTFILE} 
-#              COMMAND ${PYTHON_EXECUTABLE}
-#                      ${TESTFILE} $<CONFIGURATION>)
-#     # sys.path.insert(0, "path/to/your/package")
-#   endforeach()
-# endif(HAVE_PYTHON)
+if(NOT DISABLE_GMSH_TESTS)
+  #disabling tests is usefull when including this CMakeLists in an external project
+  include(CTest)
+  file(GLOB_RECURSE TESTFILES 
+       tutorial/*.geo demos/*.geo benchmarks/?d/*.geo benchmarks/extrude/*.geo)
+  foreach(TESTFILE ${TESTFILES})
+    # use relative path for cygwin/mingw (the pure win exe built with the mingw 
+    # compilers does not understand a full cygwin-style path)
+    FILE(RELATIVE_PATH TEST ${CMAKE_CURRENT_BINARY_DIR} ${TESTFILE})
+    add_test(${TEST} ./gmsh ${TEST} -3 -nopopup -o ./tmp.msh)
+  endforeach()
+  # if(HAVE_PYTHON)
+  #   file(GLOB_RECURSE TESTFILES tutorial/*.py)
+  #   foreach(TESTFILE ${TESTFILES})
+  #     add_test(NAME ${TESTFILE} 
+  #              COMMAND ${PYTHON_EXECUTABLE}
+  #                      ${TESTFILE} $<CONFIGURATION>)
+  #     # sys.path.insert(0, "path/to/your/package")
+  #   endforeach()
+  # endif(HAVE_PYTHON)
+endif(NOT DISABLE_GMSH_TESTS)
 
 message(STATUS "")
 message(STATUS "Gmsh ${GMSH_VERSION} has been configured for ${GMSH_OS}")
-- 
GitLab