arved
arved

Reputation: 4576

appending to AM_CXXFLAGS does not work

In configure.ac i have defined AM_CXXFLAGS

AC_SUBS([AM_CXXFLAGS], "-Wall -Wextra -Werror -std=gnu++11"])

in Makefile.am i need to disable a warning in my program

bin_Programs = foo bar

# Works
foo_CXXFLAGS = $(AM_CXXFLAGS) -Wno-error=unused
foo_SOURCES = foo.cc

# Does not work, results in CXXFLAGS being just the -Wno-error=unused
bar_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include
bar_CXXFLAGS = $(AM_CXXFLAGS) -Wno-error=unused
bar_SOURCES = bar.cc

Why doesn't it work for bar? How to fix it?

Sidenote: The vim syntax highlighter marks the second AM_CXXFLAGS as red

Upvotes: 2

Views: 1635

Answers (1)

DanielKO
DanielKO

Reputation: 4527

First, it should be bin_PROGRAMS, not bin_Programs. It's AC_SUBST, not AC_SUBS.

Don't change AM_*FLAGS from the configure script, that's not how they are supposed to be used.

See the FAQ, it has an example of what you are trying to do; you should be AC_SUBSTing into a new variable, like WARNINGCFLAGS, and have the Makefile.am like:

AM_CXXFLAGS = $(WARNINGCFLAGS) -Wno-error=unused

and drop the {foo|bar}_CXXFLAGS altogether, as they are not needed after this change.

Upvotes: 4

Related Questions