test: allow use of system gmock/gtest libs

Some systems provide prebuilt copies of gmock/gtest (such as Chromium
OS).  Add a configure flag so they can take advantage of that.  This
allows for a smaller checkout as they don't need to include the full
testing/ tree.

BUG=chromium:579384
TEST=`make check` passes w/--enable-system-test-libs
TEST=`make check` passes w/--disable-system-test-libs
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1638653002 .
This commit is contained in:
Mike Frysinger 2016-01-25 19:27:56 -05:00
parent 4b5dcd0e69
commit f820ead901
5 changed files with 384 additions and 50 deletions

257
configure vendored
View file

@ -628,6 +628,14 @@ LTLIBOBJS
LIBOBJS
SELFTEST_FALSE
SELFTEST_TRUE
GTEST_LIBS
GTEST_CFLAGS
GTEST_CONFIG
GMOCK_LIBS
GMOCK_CFLAGS
GMOCK_CONFIG
SYSTEM_TEST_LIBS_FALSE
SYSTEM_TEST_LIBS_TRUE
DISABLE_TOOLS_FALSE
DISABLE_TOOLS_TRUE
DISABLE_PROCESSOR_FALSE
@ -763,6 +771,7 @@ enable_m32
enable_largefile
enable_processor
enable_tools
enable_system_test_libs
enable_selftest
'
ac_precious_vars='build_alias
@ -778,7 +787,13 @@ CCASFLAGS
CPP
CXX
CXXFLAGS
CCC'
CCC
GMOCK_CONFIG
GMOCK_CFLAGS
GMOCK_LIBS
GTEST_CONFIG
GTEST_CFLAGS
GTEST_LIBS'
# Initialize some variables set by options.
@ -1410,6 +1425,9 @@ Optional Features:
--disable-largefile omit support for large files
--disable-processor Don't build processor library (default is no)
--disable-tools Don't build tool binaries (default is no)
--enable-system-test-libs
Use gtest/gmock/etc... from the system instead of
the local copies (default is local)
--enable-selftest Run extra tests with "make check" (may conflict with
optimizations) (default is no)
@ -1426,6 +1444,16 @@ Some influential environment variables:
CPP C preprocessor
CXX C++ compiler command
CXXFLAGS C++ compiler flags
GMOCK_CONFIG
Path to gmock-config script
GMOCK_CFLAGS
Compiler flags for gmock
GMOCK_LIBS Linker flags for gmock
GTEST_CONFIG
Path to gtest-config script
GTEST_CFLAGS
Compiler flags for gtest
GTEST_LIBS Linker flags for gtest
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@ -7453,6 +7481,229 @@ if test x$LINUX_HOST = xfalse -a x$disable_processor = xtrue -a x$disable_tools
as_fn_error $? "--disable-processor and --disable-tools were specified, and not building for Linux. Nothing to build!" "$LINENO" 5
fi
# Check whether --enable-system-test-libs was given.
if test "${enable_system_test_libs+set}" = set; then :
enableval=$enable_system_test_libs; case "${enableval}" in
yes)
system_test_libs=true
;;
no)
system_test_libs=false
;;
*)
as_fn_error $? "bad value ${enableval} for --enable-system-test-libs" "$LINENO" 5
;;
esac
else
system_test_libs=false
fi
if test x$system_test_libs = xtrue; then
SYSTEM_TEST_LIBS_TRUE=
SYSTEM_TEST_LIBS_FALSE='#'
else
SYSTEM_TEST_LIBS_TRUE='#'
SYSTEM_TEST_LIBS_FALSE=
fi
if test x$system_test_libs = xtrue; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}gmock-config", so it can be a program name with args.
set dummy ${ac_tool_prefix}gmock-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_GMOCK_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$GMOCK_CONFIG"; then
ac_cv_prog_GMOCK_CONFIG="$GMOCK_CONFIG" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_GMOCK_CONFIG="${ac_tool_prefix}gmock-config"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
GMOCK_CONFIG=$ac_cv_prog_GMOCK_CONFIG
if test -n "$GMOCK_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMOCK_CONFIG" >&5
$as_echo "$GMOCK_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_GMOCK_CONFIG"; then
ac_ct_GMOCK_CONFIG=$GMOCK_CONFIG
# Extract the first word of "gmock-config", so it can be a program name with args.
set dummy gmock-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_GMOCK_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_GMOCK_CONFIG"; then
ac_cv_prog_ac_ct_GMOCK_CONFIG="$ac_ct_GMOCK_CONFIG" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_GMOCK_CONFIG="gmock-config"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_GMOCK_CONFIG=$ac_cv_prog_ac_ct_GMOCK_CONFIG
if test -n "$ac_ct_GMOCK_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_GMOCK_CONFIG" >&5
$as_echo "$ac_ct_GMOCK_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_GMOCK_CONFIG" = x; then
GMOCK_CONFIG=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
GMOCK_CONFIG=$ac_ct_GMOCK_CONFIG
fi
else
GMOCK_CONFIG="$ac_cv_prog_GMOCK_CONFIG"
fi
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}gtest-config", so it can be a program name with args.
set dummy ${ac_tool_prefix}gtest-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_GTEST_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$GTEST_CONFIG"; then
ac_cv_prog_GTEST_CONFIG="$GTEST_CONFIG" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_GTEST_CONFIG="${ac_tool_prefix}gtest-config"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
GTEST_CONFIG=$ac_cv_prog_GTEST_CONFIG
if test -n "$GTEST_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $GTEST_CONFIG" >&5
$as_echo "$GTEST_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_GTEST_CONFIG"; then
ac_ct_GTEST_CONFIG=$GTEST_CONFIG
# Extract the first word of "gtest-config", so it can be a program name with args.
set dummy gtest-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_GTEST_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_GTEST_CONFIG"; then
ac_cv_prog_ac_ct_GTEST_CONFIG="$ac_ct_GTEST_CONFIG" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_GTEST_CONFIG="gtest-config"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_GTEST_CONFIG=$ac_cv_prog_ac_ct_GTEST_CONFIG
if test -n "$ac_ct_GTEST_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_GTEST_CONFIG" >&5
$as_echo "$ac_ct_GTEST_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_GTEST_CONFIG" = x; then
GTEST_CONFIG=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
GTEST_CONFIG=$ac_ct_GTEST_CONFIG
fi
else
GTEST_CONFIG="$ac_cv_prog_GTEST_CONFIG"
fi
GMOCK_CFLAGS=`$GMOCK_CONFIG --cppflags --cxxflags`
GMOCK_LIBS=`$GMOCK_CONFIG --ldflags --libs`
GTEST_CFLAGS=`$GTEST_CONFIG --cppflags --cxxflags`
GTEST_LIBS=`$GTEST_CONFIG --ldflags --libs`
fi
# Check whether --enable-selftest was given.
if test "${enable_selftest+set}" = set; then :
enableval=$enable_selftest; case "${enableval}" in
@ -7650,6 +7901,10 @@ if test -z "${DISABLE_TOOLS_TRUE}" && test -z "${DISABLE_TOOLS_FALSE}"; then
as_fn_error $? "conditional \"DISABLE_TOOLS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${SYSTEM_TEST_LIBS_TRUE}" && test -z "${SYSTEM_TEST_LIBS_FALSE}"; then
as_fn_error $? "conditional \"SYSTEM_TEST_LIBS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${SELFTEST_TRUE}" && test -z "${SELFTEST_FALSE}"; then
as_fn_error $? "conditional \"SELFTEST\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5