Parcourir la source

[trac1999] build libgtest.a is using --with-gtest-source

(also removed an extra space out of an unrelated output)
Jeremy C. Reed il y a 12 ans
Parent
commit
0e338764b6
2 fichiers modifiés avec 26 ajouts et 12 suppressions
  1. 7 1
      Makefile.am
  2. 19 11
      configure.ac

+ 7 - 1
Makefile.am

@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4macros ${ACLOCAL_FLAGS}
 # ^^^^^^^^ This has to be the first line and cannot come later in this
 # ^^^^^^^^ This has to be the first line and cannot come later in this
 # Makefile.am due to some bork in some versions of autotools.
 # Makefile.am due to some bork in some versions of autotools.
 
 
-SUBDIRS = compatcheck doc src tests
+SUBDIRS = compatcheck doc . src tests
 USE_LCOV=@USE_LCOV@
 USE_LCOV=@USE_LCOV@
 LCOV=@LCOV@
 LCOV=@LCOV@
 GENHTML=@GENHTML@
 GENHTML=@GENHTML@
@@ -427,3 +427,9 @@ pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = dns++.pc
 pkgconfig_DATA = dns++.pc
 
 
 CLEANFILES = $(abs_top_builddir)/logger_lockfile
 CLEANFILES = $(abs_top_builddir)/logger_lockfile
+
+if HAVE_GTEST_SOURCE
+noinst_LIBRARIES = libgtest.a
+libgtest_a_CXXFLAGS = $(GTEST_INCLUDES) $(AM_CXXFLAGS)
+nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc
+endif

+ 19 - 11
configure.ac

@@ -455,12 +455,13 @@ AC_SUBST(PYCOVERAGE_RUN)
 AC_SUBST(USE_PYCOVERAGE)
 AC_SUBST(USE_PYCOVERAGE)
 
 
 enable_gtest="no"
 enable_gtest="no"
+GTEST_INCLUDES=
 
 
 AC_ARG_WITH([gtest-source],
 AC_ARG_WITH([gtest-source],
             [AS_HELP_STRING([--with-gtest-source=PATH],
             [AS_HELP_STRING([--with-gtest-source=PATH],
                             [location of the Googletest source, defaults to /usr/src/gtest])],
                             [location of the Googletest source, defaults to /usr/src/gtest])],
             [enable_gtest="yes" ; GTEST_SOURCE="$withval";
             [enable_gtest="yes" ; GTEST_SOURCE="$withval";
-             GTEST_CPPFLAGS="-I$withval/include"],
+             GTEST_INCLUDES="-I$withval -I$withval/include"],
             [GTEST_SOURCE="/usr/src/gtest"])
             [GTEST_SOURCE="/usr/src/gtest"])
 
 
 AC_ARG_WITH([gtest],
 AC_ARG_WITH([gtest],
@@ -823,12 +824,17 @@ AC_SUBST(MULTITHREADING_FLAG)
 #
 #
 # Check availability of gtest, which will be used for unit tests.
 # Check availability of gtest, which will be used for unit tests.
 #
 #
-if test "x$enable_gtest" = "xyes"
-then
+GTEST_LDFLAGS=
+GTEST_LDADD=
+DISTCHECK_GTEST_CONFIGURE_FLAG=
+if test "x$enable_gtest" = "xyes" ; then
 	DISTCHECK_GTEST_CONFIGURE_FLAG="--enable-gtest"
 	DISTCHECK_GTEST_CONFIGURE_FLAG="--enable-gtest"
 
 
 	if test -n "$with_gtest_source" ; then
 	if test -n "$with_gtest_source" ; then
 
 
+# TODO: actually need to check if needs pthread
+GTEST_LDADD="$GTEST_LDADD $PTHREAD_LDFLAGS"
+
           if test "x$GTEST_SOURCE" = "xyes" ; then
           if test "x$GTEST_SOURCE" = "xyes" ; then
 
 
             # If not specified, try some common paths.
             # If not specified, try some common paths.
@@ -845,9 +851,12 @@ AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
                [AC_MSG_ERROR(no gtest source but it was selected)])
                [AC_MSG_ERROR(no gtest source but it was selected)])
 
 
 		DISTCHECK_GTEST_CONFIGURE_FLAG="$DISTCHECK_GTEST_CONFIGURE_FLAG $GTEST_SOURCE"
 		DISTCHECK_GTEST_CONFIGURE_FLAG="$DISTCHECK_GTEST_CONFIGURE_FLAG $GTEST_SOURCE"
+		GTEST_LDFLAGS="\$(top_builddir)/libgtest.a"
           fi
           fi
         fi
         fi
 
 
+  if test "$gtest_path" != "no" ; then
+
 	if test "$gtest_path" != "yes"; then
 	if test "$gtest_path" != "yes"; then
 		GTEST_PATHS=$gtest_path
 		GTEST_PATHS=$gtest_path
 		if test -x "${gtest_path}/bin/gtest-config" ; then
 		if test -x "${gtest_path}/bin/gtest-config" ; then
@@ -926,17 +935,16 @@ AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
 	if test "${GTEST_FOUND}" != "true"; then
 	if test "${GTEST_FOUND}" != "true"; then
 		AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
 		AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
 	fi
 	fi
-else
-	GTEST_INCLUDES=
-	GTEST_LDFLAGS=
-	GTEST_LDADD=
-	DISTCHECK_GTEST_CONFIGURE_FLAG=
+
+  fi
 fi
 fi
-AM_CONDITIONAL(HAVE_GTEST, test $gtest_path != "no")
+AM_CONDITIONAL(HAVE_GTEST, test $enable_gtest != "no")
+AM_CONDITIONAL(HAVE_GTEST_SOURCE, test "X$have_gtest_source" = "Xyes")
 AC_SUBST(DISTCHECK_GTEST_CONFIGURE_FLAG)
 AC_SUBST(DISTCHECK_GTEST_CONFIGURE_FLAG)
 AC_SUBST(GTEST_INCLUDES)
 AC_SUBST(GTEST_INCLUDES)
 AC_SUBST(GTEST_LDFLAGS)
 AC_SUBST(GTEST_LDFLAGS)
 AC_SUBST(GTEST_LDADD)
 AC_SUBST(GTEST_LDADD)
+AC_SUBST(GTEST_SOURCE)
 
 
 dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
 dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
 AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes, no)
 AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes, no)
@@ -1336,12 +1344,12 @@ Features:
   $enable_features
   $enable_features
 
 
 Developer:
 Developer:
-  Google Tests:  $gtest_path
+  Google Tests: $enable_gtest
   Valgrind: $found_valgrind
   Valgrind: $found_valgrind
   C++ Code Coverage: $USE_LCOV
   C++ Code Coverage: $USE_LCOV
   Python Code Coverage: $USE_PYCOVERAGE
   Python Code Coverage: $USE_PYCOVERAGE
   Logger checks: $enable_logger_checks
   Logger checks: $enable_logger_checks
-  Generate Manuals:  $enable_man
+  Generate Manuals: $enable_man
 
 
 END
 END