From b4d33e95df80292b06b48837fca0c65a29607dc5 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Mon, 22 Feb 2016 23:25:47 -0500 Subject: [PATCH] Fall back to using pkg-config if cppunit-config is not found Latest versions of CppUnit removed cppunit-config and use pkg-config instead, so try the latter if the former is not found to detect CppUnit under Fedora 24 for example. Closes #17387. --- configure | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++-- configure.in | 10 ++++++- 2 files changed, 92 insertions(+), 3 deletions(-) diff --git a/configure b/configure index e405425204..217955794b 100755 --- a/configure +++ b/configure @@ -1398,7 +1398,9 @@ WEBKIT_LIBS CAIRO_CFLAGS CAIRO_LIBS GST_CFLAGS -GST_LIBS' +GST_LIBS +CPPUNIT_CFLAGS +CPPUNIT_LIBS' ac_subdirs_all='src/tiff src/expat' @@ -2390,6 +2392,10 @@ Some influential environment variables: CAIRO_LIBS linker flags for CAIRO, overriding pkg-config GST_CFLAGS C compiler flags for GST, overriding pkg-config GST_LIBS linker flags for GST, overriding pkg-config + CPPUNIT_CFLAGS + C compiler flags for CPPUNIT, overriding pkg-config + CPPUNIT_LIBS + linker flags for CPPUNIT, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -39183,7 +39189,82 @@ $as_echo "no" >&6; } else CPPUNIT_CFLAGS="" CPPUNIT_LIBS="" - : + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CPPUNIT" >&5 +$as_echo_n "checking for CPPUNIT... " >&6; } + +if test -n "$PKG_CONFIG"; then + if test -n "$CPPUNIT_CFLAGS"; then + pkg_cv_CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS" + else + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cppunit >= 1.8.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "cppunit >= 1.8.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_CPPUNIT_CFLAGS=`$PKG_CONFIG --cflags "cppunit >= 1.8.0" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi +if test -n "$PKG_CONFIG"; then + if test -n "$CPPUNIT_LIBS"; then + pkg_cv_CPPUNIT_LIBS="$CPPUNIT_LIBS" + else + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cppunit >= 1.8.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "cppunit >= 1.8.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_CPPUNIT_LIBS=`$PKG_CONFIG --libs "cppunit >= 1.8.0" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + CPPUNIT_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "cppunit >= 1.8.0"` + else + CPPUNIT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "cppunit >= 1.8.0"` + fi + # Put the nasty error message in config.log where it belongs + echo "$CPPUNIT_PKG_ERRORS" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cppunit not found" >&5 +$as_echo "$as_me: WARNING: cppunit not found" >&2;} + +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cppunit not found" >&5 +$as_echo "$as_me: WARNING: cppunit not found" >&2;} + +else + CPPUNIT_CFLAGS=$pkg_cv_CPPUNIT_CFLAGS + CPPUNIT_LIBS=$pkg_cv_CPPUNIT_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SUBDIRS="$SUBDIRS tests" +fi + + fi diff --git a/configure.in b/configure.in index ed87180831..28ecf95d70 100644 --- a/configure.in +++ b/configure.in @@ -8040,7 +8040,15 @@ else SUBDIRS="samples utils" fi dnl Add tests to the list of subdirs if cppunit 1.8.0+ is detected -AM_PATH_CPPUNIT(1.8.0, [SUBDIRS="$SUBDIRS tests"]) +AM_PATH_CPPUNIT(1.8.0, + [SUBDIRS="$SUBDIRS tests"], + [ + PKG_CHECK_MODULES(CPPUNIT, [cppunit >= 1.8.0], + [SUBDIRS="$SUBDIRS tests"], + [AC_MSG_WARN([cppunit not found])] + ) + ] +) for subdir in $SUBDIRS; do if test -d ${srcdir}/${subdir} ; then