@@ -190,6 +190,16 @@ AC_ARG_ENABLE([ccache],
190190 [ use_ccache=$enableval] ,
191191 [ use_ccache=auto] )
192192
193+ dnl Suppress warnings from external headers (e.g. Boost, Qt).
194+ dnl May be useful if warnings from external headers clutter the build output
195+ dnl too much, so that it becomes difficult to spot Bitcoin Core warnings
196+ dnl or if they cause a build failure with --enable-werror.
197+ AC_ARG_ENABLE ( [ suppress-external-warnings] ,
198+ [ AS_HELP_STRING ( [ --enable-suppress-external-warnings] ,
199+ [ Suppress warnings from external headers (default is no)] ) ] ,
200+ [ suppress_external_warnings=$enableval] ,
201+ [ suppress_external_warnings=no] )
202+
193203AC_ARG_ENABLE ( [ lcov] ,
194204 [ AS_HELP_STRING ( [ --enable-lcov] ,
195205 [ enable lcov testing (default is no)] ) ] ,
@@ -1149,6 +1159,18 @@ AC_SUBST(LEVELDB_CPPFLAGS)
11491159AC_SUBST ( LIBLEVELDB )
11501160AC_SUBST ( LIBMEMENV )
11511161
1162+ dnl SUPPRESSED_CPPFLAGS=SUPPRESS_WARNINGS([$SOME_CPPFLAGS])
1163+ dnl Replace -I with -isystem in $SOME_CPPFLAGS to suppress warnings from
1164+ dnl headers from its include directories and return the result.
1165+ dnl See -isystem documentation:
1166+ dnl https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html
1167+ dnl https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-isystem-directory
1168+ dnl Do not change "-I/usr/include" to "-isystem /usr/include" because that
1169+ dnl is not necessary (/usr/include is already a system directory) and because
1170+ dnl it would break GCC's #include_next.
1171+ AC_DEFUN ( [ SUPPRESS_WARNINGS] ,
1172+ [ $(echo $1 |${SED} -E -e 's/(^| )-I/\1-isystem /g' -e 's;-isystem /usr/include ( [ / ] |$ ) ;-I/usr/include\1;g')] )
1173+
11521174dnl enable-fuzz should disable all other targets
11531175if test "x$enable_fuzz" = "xyes"; then
11541176 AC_MSG_WARN ( enable-fuzz will disable all other targets )
@@ -1170,11 +1192,22 @@ else
11701192
11711193 dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
11721194 BITCOIN_QT_CONFIGURE([ 5.5.1] )
1195+
1196+ dnl Keep a copy of the original $QT_INCLUDES and use it when invoking qt's moc
1197+ QT_INCLUDES_UNSUPPRESSED=$QT_INCLUDES
1198+ if test x$suppress_external_warnings != xno ; then
1199+ QT_INCLUDES=SUPPRESS_WARNINGS($QT_INCLUDES)
1200+ QT_DBUS_INCLUDES=SUPPRESS_WARNINGS($QT_DBUS_INCLUDES)
1201+ QT_TEST_INCLUDES=SUPPRESS_WARNINGS($QT_TEST_INCLUDES)
1202+ fi
11731203fi
11741204
11751205if test x$enable_wallet != xno; then
11761206 dnl Check for libdb_cxx only if wallet enabled
11771207 BITCOIN_FIND_BDB48
1208+ if test x$suppress_external_warnings != xno ; then
1209+ BDB_CPPFLAGS=SUPPRESS_WARNINGS($BDB_CPPFLAGS)
1210+ fi
11781211fi
11791212
11801213dnl Check for libminiupnpc (optional)
@@ -1229,6 +1262,10 @@ AX_BOOST_THREAD
12291262dnl Opt-in to boost-process
12301263AS_IF ( [ test x$with_boost_process != x ] , [ AX_BOOST_PROCESS ] , [ ax_cv_boost_process=no ] )
12311264
1265+ if test x$suppress_external_warnings != xno; then
1266+ BOOST_CPPFLAGS=SUPPRESS_WARNINGS($BOOST_CPPFLAGS)
1267+ fi
1268+
12321269dnl Boost 1.56 through 1.62 allow using std::atomic instead of its own atomic
12331270dnl counter implementations. In 1.63 and later the std::atomic approach is default.
12341271m4_pattern_allow ( DBOOST_AC_USE_STD_ATOMIC ) dnl otherwise it's treated like a macro
0 commit comments