Repository: mesos Updated Branches: refs/heads/master 5643f64b1 -> 0375e988d
MESOS-1171: unbundle gmock Enable support to build against unbundled versions of gmock. Review: https://reviews.apache.org/r/24628 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0375e988 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0375e988 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0375e988 Branch: refs/heads/master Commit: 0375e988d24406ff2b0a8fbeb7583d5d24317147 Parents: 5643f64 Author: Timothy St. Clair <[email protected]> Authored: Thu Aug 14 08:49:02 2014 -0500 Committer: Timothy St. Clair <[email protected]> Committed: Thu Aug 14 08:49:02 2014 -0500 ---------------------------------------------------------------------- 3rdparty/libprocess/3rdparty/Makefile.am | 28 +++++---- .../libprocess/3rdparty/gmock_sources.cc.in | 19 ++++++ 3rdparty/libprocess/configure.ac | 63 ++++++++++++++++++++ configure.ac | 7 +++ 4 files changed, 107 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/0375e988/3rdparty/libprocess/3rdparty/Makefile.am ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/Makefile.am b/3rdparty/libprocess/3rdparty/Makefile.am index ea46d6a..db9766d 100644 --- a/3rdparty/libprocess/3rdparty/Makefile.am +++ b/3rdparty/libprocess/3rdparty/Makefile.am @@ -94,20 +94,25 @@ endif # Convenience library for gmock/gtest. check_LTLIBRARIES = libgmock.la -nodist_libgmock_la_SOURCES = \ - $(GTEST)/src/gtest-all.cc \ - $(GMOCK)/src/gmock-all.cc -libgmock_la_CPPFLAGS = \ - -I$(GTEST)/include -I$(GTEST) \ - -I$(GMOCK)/include -I$(GMOCK) +nodist_libgmock_la_SOURCES = gmock_sources.cc + +if WITH_BUNDLED_GMOCK + libgmock_la_CPPFLAGS = \ + -I$(GTEST)/include -I$(GTEST) -I$(GTEST)/src \ + -I$(GMOCK)/include -I$(GMOCK) -I$(GMOCK)/src + + gmock_sources.cc: $(GMOCK)-stamp +endif + +if LINKGTEST + libgmock_la_LIBADD = -lgtest +endif # We list the sources in BUILT_SOURCES to make sure that the package # gets unarchived first. BUILT_SOURCES += $(nodist_libgmock_la_SOURCES) -$(GMOCK)/src/gmock-all.cc: $(GMOCK)-stamp -$(GTEST)/src/gtest-all.cc: $(GMOCK)-stamp if WITH_BUNDLED_GLOG # NOTE: We explicitely set GTEST_CONFIG=no so that we don't attempt to @@ -177,11 +182,14 @@ endif stout_tests_CPPFLAGS = \ -I$(srcdir)/$(STOUT)/include \ - -I$(GTEST)/include \ - -I$(GMOCK)/include \ -I$(PROTOBUF)/src \ $(AM_CPPFLAGS) +if WITH_BUNDLED_GMOCK + stout_tests_CPPFLAGS += -I$(GTEST)/include + stout_tests_CPPFLAGS += -I$(GMOCK)/include +endif + if WITH_BUNDLED_BOOST stout_tests_CPPFLAGS += -I$(BOOST) endif http://git-wip-us.apache.org/repos/asf/mesos/blob/0375e988/3rdparty/libprocess/3rdparty/gmock_sources.cc.in ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/gmock_sources.cc.in b/3rdparty/libprocess/3rdparty/gmock_sources.cc.in new file mode 100644 index 0000000..ba31407 --- /dev/null +++ b/3rdparty/libprocess/3rdparty/gmock_sources.cc.in @@ -0,0 +1,19 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Due to limitation in variable substitution in Automake +// _SOURCES, target is munged here instead of in the Makefile.am. + +#include "@GTESTSRC@" +#include "@GMOCKSRC@" http://git-wip-us.apache.org/repos/asf/mesos/blob/0375e988/3rdparty/libprocess/configure.ac ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/configure.ac b/3rdparty/libprocess/configure.ac index d6695ce..f552e60 100644 --- a/3rdparty/libprocess/configure.ac +++ b/3rdparty/libprocess/configure.ac @@ -49,6 +49,7 @@ AC_CONFIG_SUBDIRS([3rdparty/stout]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([include/Makefile]) AC_CONFIG_FILES([3rdparty/Makefile]) +AC_CONFIG_FILES([3rdparty/gmock_sources.cc]) AC_ARG_ENABLE([install], AS_HELP_STRING([--enable-install], @@ -99,6 +100,13 @@ AC_ARG_WITH([glog], location prefixed by the given path]), [without_bundled_glog=yes], []) +AC_ARG_WITH([gmock], + AS_HELP_STRING([--with-gmock@<:@=DIR@:>@], + [excludes building and using the bundled gmock + package in lieu of an installed version at a + location prefixed by the given path]), + [without_bundled_gmock=yes], []) + AC_ARG_WITH([http-parser], AS_HELP_STRING([--with-http-parser@<:@=DIR@:>@], [excludes building and using the bundled http-parser @@ -163,6 +171,22 @@ if test -n "`echo $with_glog`"; then LDFLAGS="$LDFLAGS -L${with_glog}/lib" fi +GMOCKSRC="gmock-all.cc" +GTESTSRC="gtest-all.cc" + +if test -n "`echo $with_gmock`"; then + CPPFLAGS="$CPPFLAGS -I${with_gmock} -I${with_gmock}/include \ + -I${with_gmock}/src -I${with_gmock}/gtest -I${with_gmock}/gtest/include \ + -I${with_gmock}/gtest/src" + +elif test "x$enable_bundled" != "xyes"; then + CPPFLAGS="$CPPFLAGS -I/usr/src/gmock" + # On system installations the deps are handled separately. + # So insert a placeholder for substitution. + GTESTSRC="stdio.h" + check_gtest=yes +fi + if test -n "`echo $with_http-parser`"; then CPPFLAGS="$CPPFLAGS -I${with_http-parser}/include" fi @@ -173,6 +197,45 @@ if test -n "`echo $with_protobuf`"; then PROTOBUFPREFIX=${with_protobuf} fi +# Check if user has asked us to use a preinstalled gmock, or if they asked +# us to ignore all bundled libraries while compiling and linking. +if test "x$without_bundled_gmock" = "xyes" || \ + test "x$enable_bundled" != "xyes"; then + + AC_CHECK_HEADER($GMOCKSRC, + [found_gmock=yes], + []) + if test "x$found_gmock" = "xyes"; then + + if test "x$check_gtest" = "xyes"; then + AC_CHECK_LIB([gtest], + [_init], + [], + [AC_MSG_ERROR([gtest missing])]) + fi + + with_bundled_gmock=no + else + AC_MSG_ERROR([cannot find gmock +------------------------------------------------------------------- +You have requested the use of a non-bundled gmock but no suitable +gmock could be found. + +You may want specify the location of gmock by providing a prefix +path via --with-gmock=DIR, or check that the path you provided is +correct if you're already doing this. +------------------------------------------------------------------- +]) + fi +else + with_bundled_gmock=yes +fi + +AM_CONDITIONAL([WITH_BUNDLED_GMOCK], [test "x$with_bundled_gmock" = "xyes"]) +AM_CONDITIONAL([LINKGTEST], [test "check_gtest" = "xyes"]) +AC_SUBST([GMOCKSRC]) +AC_SUBST([GTESTSRC]) + # Check if user has asked us to use a preinstalled libev, or if they asked # us to ignore all bundled libraries while compiling and linking. if test "x$without_bundled_libev" = "xyes" || \ http://git-wip-us.apache.org/repos/asf/mesos/blob/0375e988/configure.ac ---------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index 5653775..e2d8371 100644 --- a/configure.ac +++ b/configure.ac @@ -172,6 +172,13 @@ AC_ARG_WITH([protobuf], location prefixed by the given path]), [without_bundled_protobuf=yes], []) +AC_ARG_WITH([gmock], + AS_HELP_STRING([--with-gmock@<:@=DIR@:>@], + [excludes building and using the bundled gmock + package in lieu of an installed version at a + location prefixed by the given path]), + [without_bundled_gmock=yes], []) + AC_ARG_WITH([cxx11], AS_HELP_STRING([--without-cxx11], [builds Mesos without C++11 support (deprecated)]),
