Skip to content

Commit 2da4367

Browse files
authored
Merge pull request #10016 from bwbarrett/feature/werror-option
build: Add argument to add -Werror to CFLAGS
2 parents 34e144a + 4e7ee74 commit 2da4367

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

config/opal_setup_cc.m4

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ AC_DEFUN([OPAL_CHECK_CC_IQUOTE],[
142142
AC_MSG_RESULT([$opal_cc_iquote])
143143
])
144144

145+
146+
# OPAL_SETUP_CC_WERROR_HANDLER()
147+
# ------------------------------
148+
# Runs right before config.status, to possibly
149+
# add -Werror to CFLAGS. Can't do this earlier
150+
# in configure, as many built-in tests generate
151+
# harmless warnings which would cause the wrong
152+
# answer.
153+
AC_DEFUN([OPAL_SETUP_CC_WERROR_HANDLER], [
154+
AS_IF([test "$enable_werror" = "yes"],
155+
[AC_MSG_NOTICE([Adding -Werror to CFLAGS])
156+
CFLAGS="$CFLAGS -Werror"])
157+
])
158+
159+
145160
# OPAL_SETUP_CC()
146161
# ---------------
147162
# Do everything required to setup the C compiler. Safe to AC_REQUIRE
@@ -312,6 +327,11 @@ AC_DEFUN([OPAL_SETUP_CC],[
312327
# warning: "-qinline" is not compatible with "-g". "-qnoinline" is being set.
313328
_OPAL_CHECK_SPECIFIC_CFLAGS(-finline-functions, finline_functions)
314329

330+
AC_ARG_ENABLE([werror],
331+
[AS_HELP_STRING([--enable-werror],
332+
[Enable -Werror to convert warnings to errors. Note that 3rd-party packages will not be built with -Werror (unless they also support the --enable-werror configure option)])])
333+
AC_CONFIG_COMMANDS_PRE([OPAL_SETUP_CC_WERROR_HANDLER])
334+
315335
# Try to enable restrict keyword
316336
RESTRICT_CFLAGS=
317337
case "$opal_c_vendor" in

0 commit comments

Comments
 (0)