Search code examples
c++autotoolsautoconfinclude-path

wxWidgets autoconf setup doesn't set include dirs as -Isystem but as -I


I have inherited a build system that uses autoconf and automake to build. I am not at all familiar with how this works except on a high level.

The build system itself works fine. However a lot of warnings are generated from system headers. In my case wxWidgets. The cause of this is that the include dir of wxWidgets is passed as -I instead of -isystem. I have searched online but I can't find how I can change this.

The following code is in the configure.ac file:

AM_OPTIONS_WXCONFIG
AM_PATH_WXCONFIG(3.0.2, wxWin=1, , ,[--debug=yes])
if test "$wxWin" != 1; then
    AC_MSG_ERROR([
                wxWidgets must be installed on your system
                but no wx-config script could be found.

                Please check that wx-config is in path, the directory
                where wxWidgets libraries are installed as returned by
                'wx-config --libs' is in the linker path (LD_LIBRARY_PATH
                or equivalent variable) and wxWidgets version is 2.9.4 or
                above.
        ])
    fi
if test "$wxWin" != 0; then
    AC_DEFINE(HAVE_WXWIDGETS,1,[define if the wxWidgets 3.0.2. or higher is available])
fi

Then there is a Makefile.am which does the following:

bin_PROGRAMS = project
project_SOURCES     =   {sources here}


project_CPPFLAGS    =   $(AM_CPPFLAGS) $(PROJECT_CPPFLAGS) $(WX_CPPFLAGS)

project_CFLAGS      =   $(AM_CFLAGS)   $(PROJECT_CFLAGS)    $(WX_CFLAGS)

project_CXXFLAGS    =   $(AM_CXXFLAGS) $(PROJECT_CXXFLAGS) $(WX_CXXFLAGS)

project_LDFLAGS         =   $(AM_LDFLAGS)

project_LDADD       =   $(AM_LIBADD)   $(WX_LIBS)

There doesn't seem an option that I can specify it as a system header in some way.

Do anyone of you know how I can tackle this?


Solution

  • The problem has nothing to do with autoconf. It's the wx-config tool that is the culprit. That tool is used to obtain the include directories. For instance invoking wx-config --cxxflag will result in this:

    -I/usr/lib/wx/include/gtk2-unicode-3.1 -I/usr/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread
    

    Which is passed to the compiler. There are a couple of ways of solving this. Either manually replace it in the output or patch wx-config.