wxWidgets autoconf setup 没有设置 include dirs as -Isystem 而是 as -I

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

我继承了一个使用autoconf和automake进行构建的构建系统。我一点也不熟悉它是如何工作的,除非是在高层次上。

构建系统本身运行良好。但是,系统 headers 会生成很多警告。在我的例子中是 wxWidgets。原因是 wxWidgets 的 include 目录被传递为 -I 而不是 -isystem。我在网上搜索过,但找不到如何更改它。

以下代码在 configure.ac 文件中:

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

然后有一个 Makefile.am 执行以下操作:

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)

似乎没有选项可以让我以某种方式将其指定为系统 header。

你们有人知道我该如何解决这个问题吗?

问题与autoconf无关。罪魁祸首是 wx-config 工具。该工具用于获取包含目录。例如调用 wx-config --cxxflag 将导致:

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

传递给编译器。有几种方法可以解决这个问题。在输出中手动替换它或修补 wx-config.