Autotools:特定子目录的标志

Autotools: flags for specific sub directory

在我们由 autotools 管理的 C 项目中,我们具有以下(高级)目录结构:

<project>
 +--- configure.ac    1024 bytes
 +--- Makefile.am     1024 bytes
 +--- include         <DIR>
   +--- Makefile.am   1023 bytes
 +---source           <DIR>
   +--- Makefile.am   1022 bytes
 +--- 3rdparty        <DIR>
   +--- Makefile.am   1021 bytes

3rdparty 目录包含的源代码不是我们编写的,但无论如何都已编译并链接到主应用程序中。不幸的是,这个目录包含很多编译时警告,我们不想修复。

如何禁用 3rdparty 及其子目录中所有源文件的警告(使用 -w 标志)?

@fritzone,要在 third-party 项目中禁用警告很困难。要在您自己的项目中使用 更严格的 编译器标志时忽略这些警告,可以这样做:

https://github.com/rubicks/autotool-subdirs

tldr; 3rdparty/Makefile.am 使用默认警告; src/Makefile.am 使用非常严格的警告(视为错误)并使用 -isystem(而不是 -I)添加 3rdparty 包含路径。

该项目看起来应该很眼熟:

.
├── 3rdparty
│   ├── Makefile.am
│   ├── third.c
│   └── third.h
├── Makefile.am
├── autosub-top.h
├── configure.ac
├── include
│   ├── Makefile.am
│   └── autosub.h
└── src
    ├── Makefile.am
    ├── autosub.c
    └── prog.c

3rdparty/third.h 包含 warn-able 类似

的内容
static const size_t answer = -42;

包含在 src/autosub.c 中。 src/Makefile.am

编译 src/autosub.c
AM_CFLAGS =        \
  -Wall            \
  -Wconversion     \
  -Werror          \
  -Wextra          \
  -pedantic-errors \
  -std=c99

libthird.la

中的链接