@@ -190,6 +190,16 @@ AC_ARG_ENABLE([ccache],
190
190
[ use_ccache=$enableval] ,
191
191
[ use_ccache=auto] )
192
192
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
+
193
203
AC_ARG_ENABLE ( [ lcov] ,
194
204
[ AS_HELP_STRING ( [ --enable-lcov] ,
195
205
[ enable lcov testing (default is no)] ) ] ,
@@ -1149,6 +1159,18 @@ AC_SUBST(LEVELDB_CPPFLAGS)
1149
1159
AC_SUBST ( LIBLEVELDB )
1150
1160
AC_SUBST ( LIBMEMENV )
1151
1161
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
+
1152
1174
dnl enable-fuzz should disable all other targets
1153
1175
if test "x$enable_fuzz" = "xyes"; then
1154
1176
AC_MSG_WARN ( enable-fuzz will disable all other targets )
@@ -1170,11 +1192,22 @@ else
1170
1192
1171
1193
dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
1172
1194
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
1173
1203
fi
1174
1204
1175
1205
if test x$enable_wallet != xno; then
1176
1206
dnl Check for libdb_cxx only if wallet enabled
1177
1207
BITCOIN_FIND_BDB48
1208
+ if test x$suppress_external_warnings != xno ; then
1209
+ BDB_CPPFLAGS=SUPPRESS_WARNINGS($BDB_CPPFLAGS)
1210
+ fi
1178
1211
fi
1179
1212
1180
1213
dnl Check for libminiupnpc (optional)
@@ -1229,6 +1262,10 @@ AX_BOOST_THREAD
1229
1262
dnl Opt-in to boost-process
1230
1263
AS_IF ( [ test x$with_boost_process != x ] , [ AX_BOOST_PROCESS ] , [ ax_cv_boost_process=no ] )
1231
1264
1265
+ if test x$suppress_external_warnings != xno; then
1266
+ BOOST_CPPFLAGS=SUPPRESS_WARNINGS($BOOST_CPPFLAGS)
1267
+ fi
1268
+
1232
1269
dnl Boost 1.56 through 1.62 allow using std::atomic instead of its own atomic
1233
1270
dnl counter implementations. In 1.63 and later the std::atomic approach is default.
1234
1271
m4_pattern_allow ( DBOOST_AC_USE_STD_ATOMIC ) dnl otherwise it's treated like a macro
0 commit comments