tags 634413 + patch quit Re: #634413 aptitude: FTBFS: ld: cannot find -lgmock
It seems that `libgmock.a' is no longer provided precompiled [1]. Attached patch compiles it from the sources provided by the `google-mock' and `libgtest-dev' packages. After applying, run autoconf and automake to update `configure' and `tests/Makefile.in'. - `configure' will now pull the source directories from two environment variables, GTEST_DIR and GMOCK_DIR, which default to `/usr/src/{gtest,gmock}' respectively - `Makefile' under `tests' will now compile `libgmock.a' and link it in as appropriate. Currently there are only simple file checks for `gmock-all.cc' and `gtest-all.cc' to determine if the required sources are present. This may not be robust enough but appears to work for now. [1] From /usr/share/doc/google-mock/README.Debian: Use of precompiled libgmock --------------------------- The Google C++ Mocking Framework uses conditional compilation for some things. Because of the C++ "One Definition Rule", gmock must be compiled with exactly the same flags as your C++ code under test. Because this is hard to manage, upstream no longer recommends using precompiled libraries.
diff --git a/configure.ac b/configure.ac index cb98741..c5980af 100644 --- a/configure.ac +++ b/configure.ac @@ -482,6 +482,21 @@ AC_SUBST(BOOST_UNIT_TEST_LIBS) ##### End Boost.Test check ##### + +AC_ARG_VAR(GTEST_DIR, [path to Google Test sources (default /usr/src/gtest)]) +AC_ARG_VAR(GMOCK_DIR, [path to Google Mock sources (default /usr/src/gmock)]) + +test "x$GTEST_DIR" = "x" && GTEST_DIR="/usr/src/gtest" +test "x$GMOCK_DIR" = "x" && GMOCK_DIR="/usr/src/gmock" + +AC_CHECK_FILE($GTEST_DIR/src/gtest-all.cc, + [], + [AC_MSG_FAILURE([Can't find the Google Test sources; install libgtest-dev.])]) +AC_CHECK_FILE($GMOCK_DIR/src/gmock-all.cc, + [], + [AC_MSG_FAILURE([Can't find the Google Mock sources; install google-mock.])]) + + PKG_CHECK_MODULES(SQLITE3, sqlite3) HAVE_GTK=1 diff --git a/tests/Makefile.am b/tests/Makefile.am index 5234d43..5e343eb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,7 +2,9 @@ MAINTAINERCLEANFILES = Makefile.in INCLUDES = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/src -I$(srcdir) BOOST_TEST_LDFLAGS = @BOOST_UNIT_TEST_LIBS@ -GMOCK_LDFLAGS = -lgmock -lgtest +GTEST_DIR = @GTEST_DIR@ +GMOCK_DIR = @GMOCK_DIR@ +GMOCK_LDFLAGS = libgmock.a AM_CPPFLAGS = -DBOOST_TEST_DYN_LINK -DSRCDIR=\"$(srcdir)\" LDADD = $(top_builddir)/src/loggers.o \ $(top_builddir)/src/generic/apt/matching/libgeneric-matching.a \ @@ -20,6 +22,8 @@ $(top_builddir)/src/generic/views/mocks/libgeneric-views-mocks.a \ -lcppunit \ $(BOOST_TEST_LDFLAGS) $(GMOCK_LDFLAGS) +noinst_LIBRARIES = libgmock.a + check_PROGRAMS = gtest_test cppunit_test boost_test gtest_test noinst_PROGRAMS = interactive_set_test @@ -28,6 +32,13 @@ TESTS = gtest_test cppunit_test boost_test gtest_test EXTRA_DIST = file_caches +libgmock_a_SOURCES = \ + $(GTEST_DIR)/src/gtest-all.cc \ + $(GMOCK_DIR)/src/gmock-all.cc + +libgmock_a_CPPFLAGS = -I$(GTEST_DIR) -I$(GMOCK_DIR) $(AM_CPPFLAGS) +libgmock_a_LIBADD = + interactive_set_test_SOURCES = interactive_set_test.cc test_choice.o test_choice_set.o test_resolver.o: $(top_srcdir)/src/generic/problemresolver/*.h