tests: add cmake ctest infrastructure so `make test` can run
[contrib/mraa.git] / CMakeLists.txt
index 8597080..9660201 100644 (file)
@@ -49,7 +49,6 @@ set (CMAKE_SWIG_FLAGS "")
 find_path (SYSTEM_USR_DIR "stdlib.h")
 include_directories (${SYSTEM_USR_DIR})
 
-option (GTEST "Build all gtests." OFF)
 option (BUILDDOC "Build all doc." OFF)
 option (BUILDSWIG "Build swig modules." ON)
 option (BUILDSWIGPYTHON "Build swig python modules." ON)
@@ -58,6 +57,7 @@ option (IPK "Generate IPK using CPack" OFF)
 option (BUILDPYTHON3 "Use python3 for building/installing" OFF)
 option (INSTALLGPIOTOOL "Install gpio tool" OFF)
 option (BUILDARCH "Override architecture to build for - override" OFF)
+option (TESTS "Override the addition of tests" ON)
 
 if (NOT BUILDARCH)
   include (TargetArch)
@@ -77,9 +77,19 @@ else ()
   message(FATAL_ERROR "Only x86 and arm platforms currently supported")
 endif()
 
-if (GTEST)
-  enable_testing ()
-  add_subdirectory (tests)
+if (BUILDSWIGPYTHON)
+  if (BUILDPYTHON3)
+    set (PYTHONBUILD_VERSION 3)
+  else ()
+    set (PYTHONBUILD_VERSION 2.7)
+  endif ()
+  find_package (PythonInterp ${PYTHONBUILD_VERSION} REQUIRED)
+  if (TESTS)
+    if (${PYTHONINTERP_FOUND})
+      enable_testing ()
+      add_subdirectory (tests)
+    endif ()
+  endif ()
 endif ()
 
 if (BUILDDOC)