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