From 5c94d449bb2b116bf1e76155e87986af20743a43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joan=20Sol=C3=A0?= <jsola@iri.upc.edu>
Date: Tue, 15 Nov 2016 23:10:05 +0100
Subject: [PATCH] [Fix] Put enable_testing() before add_subdirectory(src) fixes
 the ctest

---
 CMakeLists.txt     | 21 +++++++++++----------
 src/CMakeLists.txt |  2 ++
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 264512dd8..e2b1e20a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,6 +67,17 @@ endif()
 
 #OPTION(BUILD_DOC "Build Documentation" OFF)
 OPTION(BUILD_TESTS "Build Unit tests" ON)
+#############
+## Testing ##
+#############
+#
+if(BUILD_TESTS)
+    # Enables testing for this directory and below.
+    # Note that ctest expects to find a test file in the build directory root.
+    # Therefore, this command should be in the source directory root.
+    #include(CTest) # according to http://public.kitware.com/pipermail/cmake/2012-June/050853.html
+    enable_testing()
+endif()
 
 ADD_SUBDIRECTORY(src)
 
@@ -127,13 +138,3 @@ ELSE(UNIX)
     TARGET  uninstall)
 ENDIF(UNIX)
 
-#############
-## Testing ##
-#############
-#
-if(BUILD_TESTS)
-    # Enables testing for this directory and below.
-    # Note that ctest expects to find a test file in the build directory root.
-    # Therefore, this command should be in the source directory root.
-    enable_testing()
-endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 267261078..9261ffff1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -24,6 +24,8 @@ option(BUILD_EXAMPLES "Build examples" ON)
 IF(BUILD_EXAMPLES)
   set(_WOLF_ROOT_DIR ${CMAKE_SOURCE_DIR})
 ENDIF(BUILD_EXAMPLES)
+#
+# yes, for the tests !
 IF(BUILD_TESTS)
   set(_WOLF_ROOT_DIR ${CMAKE_SOURCE_DIR})
 ENDIF(BUILD_TESTS)
-- 
GitLab