diff --git a/CMakeLists.txt b/CMakeLists.txt
index fe1f5e836c2a516ce953fab4a6dd0b8a79ea6bac..3c619c1f16e91788b7a0778170c7a9b55e417d76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1669,10 +1669,13 @@ endif(ENABLE_WRAP_JAVA)
 include(CPack)
 
 include(CTest)
-file(GLOB_RECURSE TESTFILES tutorial/*.geo demos/*.geo 
-                            benchmarks/?d/*.geo benchmarks/extrude/*.geo)
+file(GLOB_RECURSE TESTFILES 
+     tutorial/*.geo demos/*.geo benchmarks/?d/*.geo benchmarks/extrude/*.geo)
 foreach(TESTFILE ${TESTFILES})
-  add_test(${TESTFILE} ./gmsh ${TESTFILE} -3 -nopopup -o ./tmp.msh)
+  # 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(${TESTFILE} ./gmsh ${TEST} -3 -nopopup -o ./tmp.msh)
 endforeach()
 # if(HAVE_PYTHON)
 #   file(GLOB_RECURSE TESTFILES tutorial/*.py)