summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac4
-rw-r--r--m4/gtest.m465
2 files changed, 41 insertions, 28 deletions
diff --git a/configure.ac b/configure.ac
index 8e06bffd..2e9cc36d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,7 +60,7 @@ AC_CHECK_HEADER(google/dense_hash_map,
[AC_DEFINE([HAVE_SPARSEHASH], [], [flag for google::dense_hash_map])])
AC_PROG_INSTALL
-GTEST_LIB_CHECK
+GTEST_LIB_CHECK(1.0)
AM_CONDITIONAL([RAND_LM], false)
AC_ARG_WITH(randlm,
@@ -113,4 +113,4 @@ then
AM_CONDITIONAL([GLC], true)
fi
-AC_OUTPUT(Makefile utils/Makefile mteval/Makefile extools/Makefile decoder/Makefile phrasinator/Makefile training/Makefile vest/Makefile pro-train/Makefile klm/util/Makefile klm/lm/Makefile mira/Makefile gi/pyp-topics/src/Makefile gi/clda/src/Makefile)
+AC_OUTPUT(Makefile utils/Makefile mteval/Makefile extools/Makefile decoder/Makefile phrasinator/Makefile training/Makefile vest/Makefile pro-train/Makefile klm/util/Makefile klm/lm/Makefile mira/Makefile gi/pyp-topics/src/Makefile gi/clda/src/Makefile gi/cbgi/Makefile gi/ml/Makefile)
diff --git a/m4/gtest.m4 b/m4/gtest.m4
index b015ddeb..28ccd2de 100644
--- a/m4/gtest.m4
+++ b/m4/gtest.m4
@@ -12,10 +12,10 @@ AC_DEFUN([GTEST_LIB_CHECK],
dnl Provide a flag to enable or disable Google Test usage.
AC_ARG_ENABLE([gtest],
[AS_HELP_STRING([--enable-gtest],
- [Enable tests using the Google C++ Testing Framework.]
- [(Default is enabled.)])],
+ [Enable tests using the Google C++ Testing Framework.
+ (Default is enabled.)])],
[],
- [enable_gtest=check])
+ [enable_gtest=])
AC_ARG_VAR([GTEST_CONFIG],
[The exact path of Google Test's 'gtest-config' script.])
AC_ARG_VAR([GTEST_CPPFLAGS],
@@ -29,33 +29,46 @@ AC_ARG_VAR([GTEST_LIBS],
AC_ARG_VAR([GTEST_VERSION],
[The version of Google Test available.])
HAVE_GTEST="no"
-AS_IF([test "x$enable_gtest" != "xno"],
- [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
- AS_IF([test -x "$GTEST_CONFIG"],
- [AS_IF([test "x$1" != "x"],
- [_min_version="--min-version=$1"
+AS_IF([test "x${enable_gtest}" != "xno"],
+ [AC_MSG_CHECKING([for 'gtest-config'])
+ AS_IF([test "x${enable_gtest}" != "xyes"],
+ [AS_IF([test -x "${enable_gtest}/scripts/gtest-config"],
+ [GTEST_CONFIG="${enable_gtest}/scripts/gtest-config"],
+ [GTEST_CONFIG="${enable_gtest}/bin/gtest-config"])
+ AS_IF([test -x "${GTEST_CONFIG}"], [],
+ [AC_MSG_RESULT([no])
+ AC_MSG_ERROR([dnl
+Unable to locate either a built or installed Google Test.
+The specific location '${enable_gtest}' was provided for a built or installed
+Google Test, but no 'gtest-config' script could be found at this location.])
+ ])],
+ [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
+ AS_IF([test -x "${GTEST_CONFIG}"],
+ [AC_MSG_RESULT([${GTEST_CONFIG}])
+ m4_ifval([$1],
+ [_gtest_min_version="--min-version=$1"
AC_MSG_CHECKING([for Google Test at least version >= $1])],
- [_min_version="--min-version=0"
+ [_gtest_min_version="--min-version=0"
AC_MSG_CHECKING([for Google Test])])
- AS_IF([$GTEST_CONFIG $_min_version],
+ AS_IF([${GTEST_CONFIG} ${_gtest_min_version}],
[AC_MSG_RESULT([yes])
- HAVE_GTEST="yes"],
- [AC_MSG_RESULT([no])])])
- AS_IF([test "x$HAVE_GTEST" = "xyes"],
- [GTEST_CPPFLAGS=$($GTEST_CONFIG --cppflags)
- GTEST_CXXFLAGS=$($GTEST_CONFIG --cxxflags)
- GTEST_LDFLAGS=$($GTEST_CONFIG --ldflags)
- GTEST_LIBS=$($GTEST_CONFIG --libs | sed 's/la/a/')
- GTEST_VERSION=$($GTEST_CONFIG --version)
+ HAVE_GTEST='yes'],
+ [AC_MSG_RESULT([no])])],
+ [AC_MSG_RESULT([no])])
+ AS_IF([test "x${HAVE_GTEST}" = "xyes"],
+ [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
+ GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
+ GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
+ GTEST_LIBS=`${GTEST_CONFIG} --libs`
+ GTEST_VERSION=`${GTEST_CONFIG} --version`
AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])],
- [AS_IF([test "x$enable_gtest" = "xyes"],
- [AC_MSG_ERROR([
- The Google C++ Testing Framework was explicitly enabled, but a viable version
- could not be found on the system.
-])])])])
+ [AS_IF([test "x${enable_gtest}" = "xyes"],
+ [AC_MSG_ERROR([dnl
+Google Test was enabled, but no viable version could be found.])
+ ])])])
AC_SUBST([HAVE_GTEST])
AM_CONDITIONAL([HAVE_GTEST],[test "x$HAVE_GTEST" = "xyes"])
-AS_IF([test "x$HAVE_GTEST" = "xyes"],
- [AS_IF([test "x$2" != "x"],[$2],[:])],
- [AS_IF([test "x$3" != "x"],[$3],[:])])
+dnl AS_IF([test "x$HAVE_GTEST" = "xyes"], [] [])
+dnl [m4_ifval([$2], [$2])],
+dnl [m4_ifval([$3], [$3])])
])