[PATCH xorg-gtest 6/8] Build gtest as part of the project

Chase Douglas chase.douglas at canonical.com
Fri Mar 9 14:44:45 PST 2012


On 03/09/2012 01:36 PM, Gaetan Nadon wrote:
> On 12-03-09 03:45 PM, Chase Douglas wrote:
>> Google Test does not recommend using precompiled gtest libraries. See:
>>
>> http://code.google.com/p/googletest/wiki/FAQ#Why_is_it_not_recommended_to_install_a_pre-compiled_copy_of_Goog
>>
>> This change modifies the build system so the examples build the gtest
>> and xorg-gtest libraries and link against the locally built libraries
>> instead of any other precompiled libraries on the system. It uses the
>> same compiler flags to compile everything so the C++ One-Definition Rule
>> is not broken.
>>
>> Signed-off-by: Chase Douglas<chase.douglas at canonical.com>
>> ---
>>   configure.ac         |    6 +++-
>>   examples/Makefile.am |   39 ++++++++++++++++++++++++---
>>   m4/gtest.m4          |   71 ++++++++++++++++++++++++++++++++++++++-----------
>>   3 files changed, 93 insertions(+), 23 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 1082886..b5fa25d 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -20,6 +20,7 @@ AC_PROG_LIBTOOL
>>
>>   # Checks for programs.
>>   AC_PROG_CXX
>> +AC_PROG_RANLIB
>>
>>   AC_LANG([C++])
>>
>> @@ -28,13 +29,14 @@ m4_ifndef([XORG_MACROS_VERSION],
>>   	  [m4_fatal([must install xorg-macros 1.16 or later before running autoconf/autogen])])
>>   XORG_MACROS_VERSION(1.16)
>>   XORG_DEFAULT_OPTIONS
>> +XORG_ENABLE_INTEGRATION_TESTS
>>
>>   PKG_CHECK_MODULES(XSERVER, x11)
>>
>>   # Check for Google Test
>> -AC_CHECK_GTEST
>> +CHECK_GTEST
>>
>> -AS_IF([test "x$ac_cv_lib_gtest_main" != xyes],
>> +AS_IF([test "x$have_gtest" != xyes],
>>         AC_MSG_ERROR([package 'gtest' not found]))
>>
>>   AC_SUBST([GTEST_CPPFLAGS])
>> diff --git a/examples/Makefile.am b/examples/Makefile.am
>> index fcaca2b..da2485b 100644
>> --- a/examples/Makefile.am
>> +++ b/examples/Makefile.am
>> @@ -24,12 +24,41 @@
>>   # SOFTWARE.
>>   #
>>
>> -noinst_PROGRAMS = xorg-gtest-example
>> +check_LIBRARIES = libgtest.a libxorg-gtest.a libxorg-gtest_main.a
>>
>> -xorg_gtest_example_SOURCES = xorg-gtest-example.cpp
>> -
>> -AM_CPPFLAGS = -I$(top_srcdir)/include
>>   AM_CXXFLAGS = $(XSERVER_CFLAGS) $(GTEST_CPPFLAGS) $(BASE_CXXFLAGS)
>>
>> -xorg_gtest_example_LDADD = $(top_builddir)/src/libxorg-gtest.la $(top_builddir)/src/libxorg-gtest_main.la -lgtest -lpthread -lX11
>> +nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc
>> +libgtest_a_CPPFLAGS = $(GTEST_CPPFLAGS) -w
>> +libgtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
>> +
>> +libxorg_gtest_a_SOURCES = $(top_srcdir)/src/xorg-gtest-all.cpp
>> +libxorg_gtest_a_CPPFLAGS = \
>> +	$(GTEST_CPPFLAGS) \
>> +	-I$(top_srcdir)/include \
>> +	-I$(top_srcdir) \
>> +	-DDUMMY_CONF_PATH="\"$(top_srcdir)/data/xorg/gtest/dummy.conf\""
>> +libxorg_gtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
>> +
>> +libxorg_gtest_main_a_SOURCES = $(top_srcdir)/src/xorg-gtest_main.cpp
>> +libxorg_gtest_main_a_CPPFLAGS = \
>> +	$(GTEST_CPPFLAGS) \
>> +	-I$(top_srcdir)/include \
>> +	-I$(top_srcdir)
>> +libxorg_gtest_main_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS)
>> +
>> +check_PROGRAMS = xorg-gtest-example
>> +
>> +if ENABLE_INTEGRATION_TESTS
> ~/xorg/src/test/xorg-gtest$ autoreconf -vfi
> autoreconf: Entering directory `.'
> autoreconf: configure.ac: not using Gettext
> autoreconf: running: aclocal -I /home/nadon/xorg/inst/share/aclocal
> --force -I m4
> autoreconf: configure.ac: tracing
> autoreconf: configure.ac: not using Libtool
> autoreconf: running: /usr/bin/autoconf --force
> autoreconf: configure.ac: not using Autoheader
> autoreconf: running: automake --add-missing --copy --force-missing
> examples/Makefile.am:52: ENABLE_INTEGRATION_TESTS does not appear in
> AM_CONDITIONAL
> autoreconf: automake failed with exit status: 1

Oops, I forgot to send out my xorg-macros patch to add this.

Look for it on the list in a minute.

Thanks!

-- Chase


More information about the xorg-devel mailing list