From fba715aebb127dd382e83e5fb7be339bec092739 Mon Sep 17 00:00:00 2001 From: Davi Reis Date: Tue, 5 Jun 2012 00:27:17 -0300 Subject: [PATCH] Improved integration of check library. Should do the same for benchmarks. --- configure.ac | 20 ++++++++++++++------ cxxmph/Makefile.am | 10 +++++++--- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 6cb34c3..bb24aa8 100644 --- a/configure.ac +++ b/configure.ac @@ -50,12 +50,20 @@ if test x$cxxmph = xtrue; then AC_SUBST([CXXMPH], "cxxmph") fi -PKG_CHECK_MODULES([CHECK], [check >= 0.9.8], [HAVE_LIBCHECK=1], [HAVE_LIBCHECK=]) -if test "x$CHECK_LIBS" = "x" ; then - if test "x$cxxmph" = "xtrue"; then - AC_MSG_WARN([Testing library not found, make check will fail.]) - fi -fi +# Unit tests based on the check library. Disabled by default. +# We do not use pkg-config because it is inconvenient for all developers to +# have check library installed. +AC_ARG_ENABLE(check, AS_HELP_STRING( + [--enable-check], + [Build unit tests depending on check library (default: disabled)])) +AS_IF([test "x$enable_check" = "xyes"], + [ AC_CHECK_LIB([check], [tcase_create]) + AS_IF([test "$ac_cv_lib_check_tcase_create" = yes], [CHECK_LIBS="-lcheck"], + [AC_MSG_ERROR("Failed to find check library (http://check.sf.net).")]) + AC_CHECK_HEADER(check.h,[], + [AC_MSG_ERROR("Failed to find check library header (http://check.sf.net).")]) + ]) +AM_CONDITIONAL([USE_LIBCHECK], [test "$ac_cv_lib_check_tcase_create" = yes]) AC_SUBST(CHECK_LIBS) AC_SUBST(CHECK_CFLAGS) diff --git a/cxxmph/Makefile.am b/cxxmph/Makefile.am index 969cf34..349965a 100644 --- a/cxxmph/Makefile.am +++ b/cxxmph/Makefile.am @@ -1,12 +1,16 @@ TESTS = $(check_PROGRAMS) -check_PROGRAMS = test_test seeded_hash_test mph_bits_test hollow_iterator_test mph_map_test mph_index_test trigraph_test map_tester_test string_util_test -noinst_PROGRAMS = bm_index bm_map +check_PROGRAMS = seeded_hash_test mph_bits_test hollow_iterator_test mph_index_test trigraph_test string_util_test +if USE_LIBCHECK + check_PROGRAMS += test_test map_tester_test mph_map_test + check_LTLIBRARIES = libcxxmph_test.la +endif + +noinst_PROGRAMS = bm_map # bm_index - disabled because of cmph dependency bin_PROGRAMS = cxxmph cxxmph_includedir = $(includedir)/cxxmph/ cxxmph_include_HEADERS = mph_bits.h mph_map.h mph_index.h MurmurHash3.h trigraph.h seeded_hash.h stringpiece.h hollow_iterator.h string_util.h -check_LTLIBRARIES = libcxxmph_test.la noinst_LTLIBRARIES = libcxxmph_bm.la lib_LTLIBRARIES = libcxxmph.la libcxxmph_la_SOURCES = MurmurHash3.cpp trigraph.cc mph_bits.cc mph_index.cc benchmark.h benchmark.cc string_util.cc