diff --git a/Makefile.am b/Makefile.am index 66a0bd1d2..7299c91d1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ SUBDIRS = common -if TESTS +if GTEST SUBDIRS += tests endif diff --git a/configure.ac b/configure.ac index f5647bbba..cffe9f95e 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,7 @@ AC_CHECK_LIB([hiredis], [redisConnect]) AC_CHECK_LIB([nl-genl-3], [genl_connect]) AC_ARG_ENABLE(debug, -[ --enable-debug Compile with debugging flags], +[ --enable-debug Compile with debugging flags], [case "${enableval}" in yes) debug=true ;; no) debug=false ;; @@ -23,17 +23,14 @@ esac],[debug=false]) AM_CONDITIONAL(DEBUG, test x$debug = xtrue) -AC_ARG_WITH(gtest, -[ --with-gtest= Compiles tests using the location of google tests], -AC_MSG_NOTICE(Using gtest path from:$with_gtest), with_gtest="none") - -GTEST_PATH= -if test "x$with_gtest" != xnone; then -GTEST_PATH=$with_gtest -fi -AC_SUBST(GTEST_PATH) -AM_CONDITIONAL(TESTS, test "x$with_gtest" != xnone) - +AC_ARG_ENABLE(gtest, +[ --enable-gtest Compile with googletest flags], +[case "${enableval}" in + yes) gtest=true ;; + no) gtest=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-gtest) ;; +esac],[gtest=false]) +AM_CONDITIONAL(GTEST, test x$gtest = xtrue) CFLAGS_COMMON="-std=c++11 -Wall -fPIC -Wno-write-strings -I/usr/include/libnl3" AC_SUBST(CFLAGS_COMMON) diff --git a/get-gtest.sh b/get-gtest.sh new file mode 100755 index 000000000..ab5fb7186 --- /dev/null +++ b/get-gtest.sh @@ -0,0 +1,9 @@ +#!/bin/bash -ex + +git clone https://github.com/google/googletest.git +cd googletest +mkdir build +cd build +cmake .. +cmake --build . +exit 0 diff --git a/tests/Makefile.am b/tests/Makefile.am index 0e2af7720..c9cf23849 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,14 +8,14 @@ else DBGFLAGS = -g endif -CFLAGS_GTEST = -I $(GTEST_PATH)/googletest/include -LDADD_GTEST = $(GTEST_PATH)/build/googletest/libgtest_main.a \ - $(GTEST_PATH)/build/googletest/libgtest.a +CFLAGS_GTEST = -I $(top_srcdir)/googletest/googletest/include +LDADD_GTEST = $(top_srcdir)/googletest/build/googlemock/gtest/libgtest_main.a \ + $(top_srcdir)/googletest/build/googlemock/gtest/libgtest.a tests_SOURCES = redis_ut.cpp tests_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) tests_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) tests_LDADD = $(LDADD_GTEST) -lnl-genl-3 -lhiredis -lhiredis -lpthread \ - -L$(top_srcdir)/common -lswsscommon + -L$(top_srcdir)/common -lswsscommon