From 9d3a51625fabe49184537863eb07e964028b6b03 Mon Sep 17 00:00:00 2001 From: Alex Lin Date: Thu, 12 May 2016 14:42:23 -0500 Subject: [PATCH] Allow --with-gtest argument with no directory Added the option to not provide a directory name when using --with-gtest refs #237 --- autoconf/configure.ac | 8 +++++--- configure | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 554bc1b5..9b27630a 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -96,11 +96,13 @@ AC_DEFUN([AX_GTEST_HOME],[ AC_ARG_WITH([gtest], AS_HELP_STRING([--with-gtest@<:@=DIR@:>@], [GTEST root directory]), [GTEST_HOME="$withval" - AC_CHECK_FILE([$GTEST_HOME/include/gtest], + AS_IF([test "$GTEST_HOME" = "yes"], + AC_CHECK_HEADER(gtest/gtest.h,[GTEST_HOME="/usr"],AC_MSG_ERROR([could not find gtest/gtest.h])), + AC_CHECK_FILE([$GTEST_HOME/include/gtest], [], - AC_MSG_ERROR([could not find $GTEST_HOME/sample/bcuser.h]) + AC_MSG_ERROR([could not find $GTEST_HOME/include/gtest]) ) - ], + )], [GTEST_HOME=""] ) AC_SUBST([GTEST_HOME]) diff --git a/configure b/configure index 868b3085..ceb503a6 100755 --- a/configure +++ b/configure @@ -6062,7 +6062,17 @@ fi # Check whether --with-gtest was given. if test "${with_gtest+set}" = set; then : withval=$with_gtest; GTEST_HOME="$withval" - as_ac_File=`$as_echo "ac_cv_file_$GTEST_HOME/include/gtest" | $as_tr_sh` + if test "$GTEST_HOME" = "yes"; then : + ac_fn_cxx_check_header_mongrel "$LINENO" "gtest/gtest.h" "ac_cv_header_gtest_gtest_h" "$ac_includes_default" +if test "x$ac_cv_header_gtest_gtest_h" = xyes; then : + GTEST_HOME="/usr" +else + as_fn_error $? "could not find gtest/gtest.h" "$LINENO" 5 +fi + + +else + as_ac_File=`$as_echo "ac_cv_file_$GTEST_HOME/include/gtest" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $GTEST_HOME/include/gtest" >&5 $as_echo_n "checking for $GTEST_HOME/include/gtest... " >&6; } if eval \${$as_ac_File+:} false; then : @@ -6082,11 +6092,12 @@ $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes"; then : else - as_fn_error $? "could not find $GTEST_HOME/sample/bcuser.h" "$LINENO" 5 + as_fn_error $? "could not find $GTEST_HOME/include/gtest" "$LINENO" 5 fi +fi else GTEST_HOME=""