问题
I have a list of cpp files in project which is built using automake tools.
Some of them are written using pre-C++11 standard (ie C++98) and they cannot compile with c++11 flag of gcc (-std=c++11).
Latest cpp files are using C++11 standard and they need -std=c++11 flag in compile.
Can I define in Automake two lists of cpp source files and give different compilation flags?
回答1:
This is ripped directly from Setting per-file flags with automake
You may bundle your c++11 code into a lib and provide different flags for this code subset in Makefile.am
bin_PROGRAMS = test
test_SOURCES = main.cpp
test_LDADD = c11code.la
noinst_LTLIBRARIES = c11code.la
c11code_la_SOURCES = cxx1_1.cpp cxx1_2.cpp cxx1_3.cpp
c11code_la_CXXFLAGS = $(CXXFLAGS) -std=c++11
来源:https://stackoverflow.com/questions/26906219/mixing-c98-and-c11-source-in-automake-gcc