Tests require 'catch' to be installed, one might want to disable them if
catch is not available. This patch adds a --disable-tests switch. By
default, tests are enabled depending on 'catch' availability.

Signed-off-by: Christophe Fergeau <cferg...@redhat.com>
---
 configure.ac    | 21 +++++++++++++++++++--
 src/Makefile.am |  3 +++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1bb1f5d..4333c42 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,8 +38,6 @@ PKG_CHECK_MODULES(XFIXES, xfixes)
 
 PKG_CHECK_MODULES(JPEG, libjpeg)
 
-AC_CHECK_HEADER([catch/catch.hpp],,[AC_MSG_ERROR([Could not find Catch 
dependency header (catch/catch.hpp)])])
-
 dnl ===========================================================================
 dnl check compiler flags
 
@@ -50,6 +48,25 @@ LIBVIRT_LINKER_NO_INDIRECT
 AC_SUBST(WARN_CFLAGS)
 AC_SUBST(WARN_CXXFLAGS)
 
+dnl =========================================================================
+dnl tests
+AC_ARG_ENABLE([tests],
+              AS_HELP_STRING([--disable-tests=@<:@yes/no@:>@],
+                             [Disable tests (they require 'catch' to be 
installed) @<:@default=auto@:>@]),
+                             [],
+                             [enable_tests="auto"])
+case "$enable_tests" in
+  0|no) enable_tests="no" ;;
+  1|yes) enable_tests="yes" ;;
+  auto) enable_tests="auto" ;;
+  *) AC_MSG_ERROR([bad value ${enable_tests} for enable-tests option]) ;;
+esac
+AS_IF([test "x$enable_tests" != "xno"],
+      [AC_CHECK_HEADER([catch/catch.hpp],have_check="yes",)])
+AS_IF([test "x$enable_tests" = "xyes" && test "x$have_check" != "xyes"],
+      [AC_MSG_ERROR([Could not find Catch dependency header 
(catch/catch.hpp)])])
+AM_CONDITIONAL([ENABLE_TESTS], [test "x$have_check" = "xyes"])
+
 AC_DEFINE_DIR([BINDIR], [bindir], [Where binaries are installed.])
 
 AC_OUTPUT([
diff --git a/src/Makefile.am b/src/Makefile.am
index 857d763..606f51a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,10 @@
 # Copyright 2016-2017 Red Hat Inc. All rights reserved.
 
 NULL =
+
+if ENABLE_TESTS
 SUBDIRS = . unittests
+endif
 
 AM_CPPFLAGS = \
        -DSPICE_STREAMING_AGENT_PROGRAM \
-- 
2.14.3

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to