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.
This commit is contained in:
parent
a369436e2a
commit
7b3b36fde4
63
m4/gtest.m4
63
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])])
|
||||
])
|
||||
|
|
Loading…
Reference in New Issue
Block a user