From 81b104928b35d46faf200dc3265ac2254b6246c5 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Thu, 20 Apr 2017 18:44:41 +0100 Subject: [PATCH] Add building of Google Test libraries (#781978) This closely follows the minimal-gtest-autotools template project. https://github.com/octol/minimal-gtest-autotools Now 'make check' will additionally build the Google Test C++ test framework libraries. Bug 781978 - Add Google Test C++ test framework --- .gitignore | 2 ++ Makefile.am | 2 +- configure.ac | 14 ++++++++++ lib/Makefile.am | 1 + lib/gtest/Makefile.am | 61 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 lib/Makefile.am create mode 100644 lib/gtest/Makefile.am diff --git a/.gitignore b/.gitignore index ec888a09..d0cc7ab6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *~ *.a *.gmo +*.lo *.mo *.o *.omf @@ -33,6 +34,7 @@ gnome-doc-utils.make help/*/gparted.xml install-sh intltool-* +lib/gtest/lib libtool ltmain.sh m4/*.m4 diff --git a/Makefile.am b/Makefile.am index 478cbf8a..481ff2ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = compose data doc include po src +SUBDIRS = compose data doc include lib po src # Only build GParted help documentation when enabled. (Can be disabled # with './configure --disable-doc'). if BUILD_HELP_DOC diff --git a/configure.ac b/configure.ac index 7c8c0d7f..702ad3dc 100644 --- a/configure.ac +++ b/configure.ac @@ -285,6 +285,18 @@ fi +dnl Definitions for building of and with gtest. Gets flags for pthread via earlier +dnl gthread package check. +GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1" +GTEST_CXXFLAGS="$GTHREAD_CFLAGS" +GTEST_LDFLAGS= +GTEST_LIBS="$GTHREAD_LIBS" +AC_SUBST([GTEST_CPPFLAGS]) +AC_SUBST([GTEST_CXXFLAGS]) +AC_SUBST([GTEST_LDFLAGS]) +AC_SUBST([GTEST_LIBS]) + + dnl====================== dnl check whether to build documentation - gnome-doc-utils dnl====================== @@ -367,6 +379,8 @@ data/icons/Makefile doc/Makefile help/Makefile include/Makefile +lib/Makefile +lib/gtest/Makefile src/Makefile po/Makefile.in ]) diff --git a/lib/Makefile.am b/lib/Makefile.am new file mode 100644 index 00000000..b1f917b2 --- /dev/null +++ b/lib/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = gtest diff --git a/lib/gtest/Makefile.am b/lib/gtest/Makefile.am new file mode 100644 index 00000000..6d01de7b --- /dev/null +++ b/lib/gtest/Makefile.am @@ -0,0 +1,61 @@ +# Nonstandard package files for distribution +EXTRA_DIST = \ + LICENSE \ + README.md \ + include/gtest/gtest-param-test.h.pump \ + include/gtest/internal/gtest-param-util-generated.h.pump \ + include/gtest/internal/gtest-tuple.h.pump \ + include/gtest/internal/gtest-type-util.h.pump + +# gtest source files that we don't compile directly. They are +# #included by gtest-all.cc. +GTEST_SRC = \ + src/gtest-death-test.cc \ + src/gtest-filepath.cc \ + src/gtest-internal-inl.h \ + src/gtest-port.cc \ + src/gtest-printers.cc \ + src/gtest-test-part.cc \ + src/gtest-typed-test.cc \ + src/gtest.cc \ + include/gtest/gtest-death-test.h \ + include/gtest/gtest-message.h \ + include/gtest/gtest-param-test.h \ + include/gtest/gtest-printers.h \ + include/gtest/gtest-spi.h \ + include/gtest/gtest-test-part.h \ + include/gtest/gtest-typed-test.h \ + include/gtest/gtest.h \ + include/gtest/gtest_pred_impl.h \ + include/gtest/gtest_prod.h \ + include/gtest/internal/gtest-death-test-internal.h \ + include/gtest/internal/gtest-filepath.h \ + include/gtest/internal/gtest-internal.h \ + include/gtest/internal/gtest-linked_ptr.h \ + include/gtest/internal/gtest-param-util-generated.h \ + include/gtest/internal/gtest-param-util.h \ + include/gtest/internal/gtest-port.h \ + include/gtest/internal/gtest-port-arch.h \ + include/gtest/internal/gtest-string.h \ + include/gtest/internal/gtest-tuple.h \ + include/gtest/internal/gtest-type-util.h \ + include/gtest/internal/custom/gtest.h \ + include/gtest/internal/custom/gtest-port.h \ + include/gtest/internal/custom/gtest-printers.h + +EXTRA_DIST += $(GTEST_SRC) + +# We define the global AM_CPPFLAGS as everything we compile includes from these +# directories. +AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/include $(GTEST_CPPFLAGS) +AM_CXXFLAGS = $(GTEST_CXXFLAGS) +AM_LDFLAGS = $(GTEST_LDFLAGS) +LDADD = $(GTEST_LIBS) + +# Build rules for libraries. +check_LTLIBRARIES = lib/libgtest.la lib/libgtest_main.la + +lib_libgtest_la_SOURCES = src/gtest-all.cc + +lib_libgtest_main_la_SOURCES = src/gtest_main.cc +lib_libgtest_main_la_LIBADD = lib/libgtest.la