1 | dnl GTEST_LIB_CHECK([minimum version [,
|
---|
2 | dnl action if found [,action if not found]]])
|
---|
3 | dnl
|
---|
4 | dnl Check for the presence of the Google Test library, optionally at a minimum
|
---|
5 | dnl version, and indicate a viable version with the HAVE_GTEST flag. It defines
|
---|
6 | dnl standard variables for substitution including GTEST_CPPFLAGS,
|
---|
7 | dnl GTEST_CXXFLAGS, GTEST_LDFLAGS, and GTEST_LIBS. It also defines
|
---|
8 | dnl GTEST_VERSION as the version of Google Test found. Finally, it provides
|
---|
9 | dnl optional custom action slots in the event GTEST is found or not.
|
---|
10 | AC_DEFUN([GTEST_LIB_CHECK],
|
---|
11 | [
|
---|
12 | dnl Provide a flag to enable or disable Google Test usage.
|
---|
13 | AC_ARG_ENABLE([gtest],
|
---|
14 | [AS_HELP_STRING([--enable-gtest],
|
---|
15 | [Enable tests using the Google C++ Testing Framework.
|
---|
16 | (Default is enabled.)])],
|
---|
17 | [],
|
---|
18 | [enable_gtest=])
|
---|
19 | AC_ARG_VAR([GTEST_CONFIG],
|
---|
20 | [The exact path of Google Test's 'gtest-config' script.])
|
---|
21 | AC_ARG_VAR([GTEST_CPPFLAGS],
|
---|
22 | [C-like preprocessor flags for Google Test.])
|
---|
23 | AC_ARG_VAR([GTEST_CXXFLAGS],
|
---|
24 | [C++ compile flags for Google Test.])
|
---|
25 | AC_ARG_VAR([GTEST_LDFLAGS],
|
---|
26 | [Linker path and option flags for Google Test.])
|
---|
27 | AC_ARG_VAR([GTEST_LIBS],
|
---|
28 | [Library linking flags for Google Test.])
|
---|
29 | AC_ARG_VAR([GTEST_VERSION],
|
---|
30 | [The version of Google Test available.])
|
---|
31 | HAVE_GTEST="no"
|
---|
32 | AS_IF([test "x${enable_gtest}" != "xno"],
|
---|
33 | [AC_MSG_CHECKING([for 'gtest-config'])
|
---|
34 | AS_IF([test "x${enable_gtest}" != "xyes"],
|
---|
35 | [AS_IF([test -x "${enable_gtest}/scripts/gtest-config"],
|
---|
36 | [GTEST_CONFIG="${enable_gtest}/scripts/gtest-config"],
|
---|
37 | [GTEST_CONFIG="${enable_gtest}/bin/gtest-config"])
|
---|
38 | AS_IF([test -x "${GTEST_CONFIG}"], [],
|
---|
39 | [AC_MSG_RESULT([no])
|
---|
40 | AC_MSG_ERROR([dnl
|
---|
41 | Unable to locate either a built or installed Google Test.
|
---|
42 | The specific location '${enable_gtest}' was provided for a built or installed
|
---|
43 | Google Test, but no 'gtest-config' script could be found at this location.])
|
---|
44 | ])],
|
---|
45 | [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
|
---|
46 | AS_IF([test -x "${GTEST_CONFIG}"],
|
---|
47 | [AC_MSG_RESULT([${GTEST_CONFIG}])
|
---|
48 | m4_ifval([$1],
|
---|
49 | [_gtest_min_version="--min-version=$1"
|
---|
50 | AC_MSG_CHECKING([for Google Test at least version >= $1])],
|
---|
51 | [_gtest_min_version="--min-version=0"
|
---|
52 | AC_MSG_CHECKING([for Google Test])])
|
---|
53 | AS_IF([${GTEST_CONFIG} ${_gtest_min_version}],
|
---|
54 | [AC_MSG_RESULT([yes])
|
---|
55 | HAVE_GTEST='yes'],
|
---|
56 | [AC_MSG_RESULT([no])])],
|
---|
57 | [AC_MSG_RESULT([no])])
|
---|
58 | AS_IF([test "x${HAVE_GTEST}" = "xyes"],
|
---|
59 | [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
|
---|
60 | GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
|
---|
61 | GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
|
---|
62 | GTEST_LIBS=`${GTEST_CONFIG} --libs`
|
---|
63 | GTEST_VERSION=`${GTEST_CONFIG} --version`
|
---|
64 | AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])],
|
---|
65 | [AS_IF([test "x${enable_gtest}" = "xyes"],
|
---|
66 | [AC_MSG_ERROR([dnl
|
---|
67 | Google Test was enabled, but no viable version could be found.])
|
---|
68 | ])])])
|
---|
69 | AC_SUBST([HAVE_GTEST])
|
---|
70 | AM_CONDITIONAL([HAVE_GTEST],[test "x$HAVE_GTEST" = "xyes"])
|
---|
71 | AS_IF([test "x$HAVE_GTEST" = "xyes"],
|
---|
72 | [m4_ifval([$2], [$2])],
|
---|
73 | [m4_ifval([$3], [$3])])
|
---|
74 | ])
|
---|