TL;DR: When I compile an external library with a specific set of flags, how can I deal with warnings triggered by the flags used to compile my own code when I include the headers of this library ?
I am using autotools as a build system in a project and I would like to set compilation flags properly depending on the target.
I would like to compile my own sources with a somehow high level of warning (any help from the compiler to debug / prevent bugs is always welcome).
In the warning flags set currently used there is -Wsuggest-override
which I'll take as an example.
I have besides my sources an external library (pugixml
if you really want to know) which I would like to compile with, let's say -Ofast
To have two separate sets of flags,
In the info page of automake
there is an interesting section with a concrete example Per-Object Flags: How to simulate per-object flags?.
(There are also some SO question on the topic)
That's why in my Makefile.am
there is the following:
__top_srcdir__bin_LDADD = libpugixml.a
noinst_LIBRARIES = libpugixml.a
libpugixml_a_SOURCES = pugixml/pugixml.cpp
libpugixml_a_CPPFLAGS = -Ofast
The set of program sources no longer contains the library sources:
__top_srcdir__we_SOURCES = main.cc
This works fine, the library is build with a set of flags, my sources with another one, everything is ok...
Until I include a header of the library in my sources and that's why I'm posting this (too long ?) question
main.cc:
#include <pugixml/pugixml.hpp> // -Wsuggest-override triggered
int main() { return 0; }
During the compilation, the -Wsuggest-override
is triggered in the library sources
Does the official automake
solution to have different sets of warnings not not apply in this case or am I doing something wrong ?
I am not sure if it matters but I'm using g++
and/or clang
(depending on the mood)
the automake
version: automake (GNU automake) 1.15
Thanks for your help