summaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
authorshiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925>2008-12-10 18:27:39 (GMT)
committershiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925>2008-12-10 18:27:39 (GMT)
commit7b3b36fde40f0f5e9a1c7c3b941ccbee6c817019 (patch)
tree7b292803dc7fe7a101e9a267c60bda05f1fe6c08 /m4
parenta369436e2adb3f27fa5b169b85f14c56fcdc6f5b (diff)
downloadgoogletest-7b3b36fde40f0f5e9a1c7c3b941ccbee6c817019.zip
googletest-7b3b36fde40f0f5e9a1c7c3b941ccbee6c817019.tar.gz
googletest-7b3b36fde40f0f5e9a1c7c3b941ccbee6c817019.tar.bz2
A small re-work of the installed m4 script for Google Test. This
allows other projects to easily leverage an installation or un-installed build of Google Test from their project's Autoconf script. This re-work specifically introduces the ability to provide a path as an argument to the resulting configure script option which can specify either an installation prefix or a build directory for Google Test. This change also makes a small portability tweak by using ``s instead of $() for command expansion. By Chandler Carruth. Reviewed by Benoit Sigoure.
Diffstat (limited to 'm4')
-rw-r--r--m4/gtest.m463
1 files changed, 38 insertions, 25 deletions
diff --git a/m4/gtest.m4 b/m4/gtest.m4
index ebb488a..6598ba7 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)
- 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],[:])])
+ [m4_ifval([$2], [$2])],
+ [m4_ifval([$3], [$3])])
])