summaryrefslogtreecommitdiff
path: root/m4/gtest.m4
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-22 05:12:27 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-22 05:12:27 +0000
commit0172721855098ca02b207231a654dffa5e4eb1c9 (patch)
tree8069c3a62e2d72bd64a2cdeee9724b2679c8a56b /m4/gtest.m4
parent37728b8be4d0b3df9da81fdda2198ff55b4b2d91 (diff)
initial checkin
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@2 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'm4/gtest.m4')
-rw-r--r--m4/gtest.m461
1 files changed, 61 insertions, 0 deletions
diff --git a/m4/gtest.m4 b/m4/gtest.m4
new file mode 100644
index 00000000..b015ddeb
--- /dev/null
+++ b/m4/gtest.m4
@@ -0,0 +1,61 @@
+dnl GTEST_LIB_CHECK([minimum version [,
+dnl action if found [,action if not found]]])
+dnl
+dnl Check for the presence of the Google Test library, optionally at a minimum
+dnl version, and indicate a viable version with the HAVE_GTEST flag. It defines
+dnl standard variables for substitution including GTEST_CPPFLAGS,
+dnl GTEST_CXXFLAGS, GTEST_LDFLAGS, and GTEST_LIBS. It also defines
+dnl GTEST_VERSION as the version of Google Test found. Finally, it provides
+dnl optional custom action slots in the event GTEST is found or not.
+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_gtest=check])
+AC_ARG_VAR([GTEST_CONFIG],
+ [The exact path of Google Test's 'gtest-config' script.])
+AC_ARG_VAR([GTEST_CPPFLAGS],
+ [C-like preprocessor flags for Google Test.])
+AC_ARG_VAR([GTEST_CXXFLAGS],
+ [C++ compile flags for Google Test.])
+AC_ARG_VAR([GTEST_LDFLAGS],
+ [Linker path and option flags for Google Test.])
+AC_ARG_VAR([GTEST_LIBS],
+ [Library linking flags for Google Test.])
+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"
+ AC_MSG_CHECKING([for Google Test at least version >= $1])],
+ [_min_version="--min-version=0"
+ AC_MSG_CHECKING([for Google Test])])
+ AS_IF([$GTEST_CONFIG $_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)
+ 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.
+])])])])
+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],[:])])
+])