@@ -192,6 +192,13 @@ AC_ARG_ENABLE([debug],
192
192
[ enable_debug=$enableval] ,
193
193
[ enable_debug=no] )
194
194
195
+ # Turn warnings into errors
196
+ AC_ARG_ENABLE ( [ werror] ,
197
+ [ AS_HELP_STRING ( [ --enable-werror] ,
198
+ [ Treat certain compiler warnings as errors (default is no)] ) ] ,
199
+ [ enable_werror=$enableval] ,
200
+ [ enable_werror=no] )
201
+
195
202
AC_LANG_PUSH ( [ C++] )
196
203
AX_CHECK_COMPILE_FLAG ( [ -Werror] ,[ CXXFLAG_WERROR="-Werror"] ,[ CXXFLAG_WERROR=""] )
197
204
@@ -206,6 +213,14 @@ if test "x$enable_debug" = xyes; then
206
213
fi
207
214
fi
208
215
216
+ ERROR_CXXFLAGS=
217
+ if test "x$enable_werror" = "xyes"; then
218
+ if test "x$CXXFLAG_WERROR" = "x"; then
219
+ AC_MSG_ERROR ( "enable-werror set but - Werror is not usable" )
220
+ fi
221
+ AX_CHECK_COMPILE_FLAG ( [ -Werror=vla] ,[ ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"] ,,[ [ $CXXFLAG_WERROR] ] )
222
+ fi
223
+
209
224
if test "x$CXXFLAGS_overridden" = "xno"; then
210
225
AX_CHECK_COMPILE_FLAG ( [ -Wall] ,[ CXXFLAGS="$CXXFLAGS -Wall"] ,,[ [ $CXXFLAG_WERROR] ] )
211
226
AX_CHECK_COMPILE_FLAG ( [ -Wextra] ,[ CXXFLAGS="$CXXFLAGS -Wextra"] ,,[ [ $CXXFLAG_WERROR] ] )
@@ -1067,6 +1082,7 @@ AC_SUBST(BITCOIN_CLI_NAME)
1067
1082
AC_SUBST ( BITCOIN_TX_NAME )
1068
1083
1069
1084
AC_SUBST ( RELDFLAGS )
1085
+ AC_SUBST ( ERROR_CXXFLAGS )
1070
1086
AC_SUBST ( HARDENED_CXXFLAGS )
1071
1087
AC_SUBST ( HARDENED_CPPFLAGS )
1072
1088
AC_SUBST ( HARDENED_LDFLAGS )
@@ -1156,6 +1172,7 @@ echo " with test = $use_tests"
1156
1172
echo " with bench = $use_bench"
1157
1173
echo " with upnp = $use_upnp"
1158
1174
echo " debug enabled = $enable_debug"
1175
+ echo " werror = $enable_werror"
1159
1176
echo
1160
1177
echo " target os = $TARGET_OS"
1161
1178
echo " build os = $BUILD_OS"
0 commit comments