source: gtest-1.7.0/m4/gtest.m4@ 12761

Last change on this file since 12761 was 12746, checked in by hock@…, 11 years ago

integrated the Google Testing Framework (gtest)

and wrote an Hello World test, to ensure the framework is working..

File size: 3.1 KB
Line 
1dnl GTEST_LIB_CHECK([minimum version [,
2dnl action if found [,action if not found]]])
3dnl
4dnl Check for the presence of the Google Test library, optionally at a minimum
5dnl version, and indicate a viable version with the HAVE_GTEST flag. It defines
6dnl standard variables for substitution including GTEST_CPPFLAGS,
7dnl GTEST_CXXFLAGS, GTEST_LDFLAGS, and GTEST_LIBS. It also defines
8dnl GTEST_VERSION as the version of Google Test found. Finally, it provides
9dnl optional custom action slots in the event GTEST is found or not.
10AC_DEFUN([GTEST_LIB_CHECK],
11[
12dnl Provide a flag to enable or disable Google Test usage.
13AC_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=])
19AC_ARG_VAR([GTEST_CONFIG],
20 [The exact path of Google Test's 'gtest-config' script.])
21AC_ARG_VAR([GTEST_CPPFLAGS],
22 [C-like preprocessor flags for Google Test.])
23AC_ARG_VAR([GTEST_CXXFLAGS],
24 [C++ compile flags for Google Test.])
25AC_ARG_VAR([GTEST_LDFLAGS],
26 [Linker path and option flags for Google Test.])
27AC_ARG_VAR([GTEST_LIBS],
28 [Library linking flags for Google Test.])
29AC_ARG_VAR([GTEST_VERSION],
30 [The version of Google Test available.])
31HAVE_GTEST="no"
32AS_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
41Unable to locate either a built or installed Google Test.
42The specific location '${enable_gtest}' was provided for a built or installed
43Google 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
67Google Test was enabled, but no viable version could be found.])
68 ])])])
69AC_SUBST([HAVE_GTEST])
70AM_CONDITIONAL([HAVE_GTEST],[test "x$HAVE_GTEST" = "xyes"])
71AS_IF([test "x$HAVE_GTEST" = "xyes"],
72 [m4_ifval([$2], [$2])],
73 [m4_ifval([$3], [$3])])
74])
Note: See TracBrowser for help on using the repository browser.