本文介绍了使用automake设置每个文件标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个方法设置每个文件的基础与automake标志?

特别是,如果我有一个c + +项目,并希望编译-WAll除了我想要的所有文件要禁用特定的警告,我该怎么办?



我试过类似:

  CXXFLAGS = -WAll ... 
bin_PROGRAMS = test
test_SOURCES = main.cpp utility.cpp
utility_o_CXXFLAGS = $(CXXFLAGS)-Wno-unused-value

但它不起作用。



编辑:删除了对automake手册的引用,这实际上是误导性的(感谢Douglas Leeder)。 Automake仅支持每个目标标志,而你想要每个对象的标志。一种方法是创建一个包含对象的小型库:

  CXXFLAGS = -Wall ... 
bin_PROGRAMS = test
test_SOURCES = main.cpp
test_LDADD = libutility.a
noinst_LIBRARIES = libutility.a
libutility_a_SOURCES = utility.cpp
libutility_a_CXXFLAGS = $(CXXFLAGS)-Wno -unused-value


Is there a way set flags on a per-file basis with automake?
In particular, if I have a c++ project and want to compile with -WAll all the files except one for which I want to disable a particular warning, what could I do?

I tried something like:

CXXFLAGS = -WAll ...
bin_PROGRAMS = test
test_SOURCES = main.cpp utility.cpp
utility_o_CXXFLAGS = $(CXXFLAGS) -Wno-unused-value

but it didn't work.

EDITED: removed reference to automake manual, which was actually misleading (thanks to Douglas Leeder).

解决方案

Automake only supports per-target flags, while you want per-object flags. One way around is to create a small library that contains your object:

CXXFLAGS = -Wall ...
bin_PROGRAMS = test
test_SOURCES = main.cpp
test_LDADD = libutility.a
noinst_LIBRARIES = libutility.a
libutility_a_SOURCES = utility.cpp
libutility_a_CXXFLAGS = $(CXXFLAGS) -Wno-unused-value

这篇关于使用automake设置每个文件标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 10:18