1
0
mirror of https://github.com/ceph/ceph synced 2025-03-29 15:03:39 +00:00

Makefile: link gtest statically

The problem:

 - the unittests link against gtest, and gtest is not installed.  that's
   normally fine, but...
 - rbd and rados api unit tests link against gtest, and are installed
   by 'make install'.  they are needed for teuthology runs, etc.
 - if we build gtest as an .la library, we can only control whether *all*
   or *no* .la libraries are linked statically.
 - we want librados to be linked dynamically.

The solution:

 - build gtest as .a instead of a libtool library
 - link it statically, always.

Unit test binaries are bigger now.  Oh well...

Fixes: 
Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2012-06-13 11:05:43 -07:00
parent c4a607aa1f
commit 66553d25f0
4 changed files with 6 additions and 14 deletions

View File

@ -15,13 +15,13 @@ all-local:
if WITH_DEBUG
# We need gtest to build the rados-api tests. We only build those in
# a debug build, though.
@cd src/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la lib/libgtest.a lib/libgtest_main.a
@cd src/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.a lib/libgtest_main.a
endif
check-local:
# We build gtest this way, instead of using SUBDIRS, because with that,
# gtest's own tests would be run and that would slow us down.
@cd src/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
@cd src/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.a lib/libgtest_main.a
# exercise cli tools
$(srcdir)/src/test/run-cli-tests '$(top_builddir)/src/test'

View File

@ -504,14 +504,11 @@ unittests:: $(check_PROGRAMS)
UNITTEST_CXXFLAGS = \
-I$(top_srcdir)/src/gtest/include \
-I$(top_builddir)/src/gtest/include
UNITTEST_LDADD = \
$(top_builddir)/src/gtest/lib/libgtest.la \
$(top_builddir)/src/gtest/lib/libgtest_main.la \
$(PTHREAD_LIBS)
UNITTEST_STATIC_LDADD = \
$(top_builddir)/src/gtest/lib/libgtest.a \
$(top_builddir)/src/gtest/lib/libgtest_main.a \
$(PTHREAD_LIBS)
UNITTEST_LDADD = ${UNITTEST_STATIC_LDADD}
unittest_encoding_SOURCES = test/encoding.cc
unittest_encoding_LDADD = libcephfs.la librados.la $(PTHREAD_LIBS) -lm \

View File

@ -179,10 +179,8 @@ else
endif
# Build rules for libraries.
lib_LTLIBRARIES = lib/libgtest.la lib/libgtest_main.la
lib_LTLIBRARIES += lib/libgtest.a lib/libgtest_main.a
lib_LIBRARIES = lib/libgtest.a lib/libgtest_main.a
lib_libgtest_la_SOURCES = src/gtest-all.cc
lib_libgtest_a_SOURCES = src/gtest-all.cc
pkginclude_HEADERS = include/gtest/gtest.h \
@ -208,9 +206,6 @@ pkginclude_internal_HEADERS = \
include/gtest/internal/gtest-tuple.h \
include/gtest/internal/gtest-type-util.h
lib_libgtest_main_la_SOURCES = src/gtest_main.cc
lib_libgtest_main_la_LIBADD = lib/libgtest.la
lib_libgtest_main_a_SOURCES = src/gtest_main.cc
lib_libgtest_main_a_LIBADD = lib/libgtest.a
@ -247,7 +242,7 @@ samples_sample1_unittest_LDADD = lib/libgtest_main.la \
TESTS += samples/sample10_unittest
check_PROGRAMS += samples/sample10_unittest
samples_sample10_unittest_SOURCES = samples/sample10_unittest.cc
samples_sample10_unittest_LDADD = lib/libgtest.la
samples_sample10_unittest_LDADD = lib/libgtest.a
# This tests most constructs of gtest and verifies that libgtest_main
# works.

View File

@ -214,7 +214,7 @@ if test "${this_bindir}" = "${this_bindir%${bindir}}"; then
# TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we
# should work to remove it, and/or remove libtool altogether, replacing it
# with direct references to the library and a link path.
gtest_libs="${build_dir}/lib/libgtest.la @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
gtest_libs="${build_dir}/lib/libgtest.a @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
gtest_ldflags=""
# We provide hooks to include from either the source or build dir, where the