Reputation: 2017
I use AX_CXX_COMPILE_STDCXX_0X
(can look on autoconf-archive) to check for c++11 capabilities of the compiler. It correctly determines that -std=c++0x
required, but does not add it to CXXFLAGS
. I took a look at the macro source and it actually checks but then restores previous flags.
What should I do to get CXXFLAGS
set to be able to compile c++11 source?
Just adding -std=c++0x
to AM_CXXFLAGS
is not nice solution, because I'd like to put the burden of making the compiler compile in C++11 mode on the autoconf developers, not me.
Upvotes: 23
Views: 10166
Reputation: 1386
In general you can compile a simple code and set a variable based the outcome of your compilation
DIALECT="-std=c++14"
echo 'int main() {return 0;}' > ./log.cpp && $CXX -std=c++14 ./log.cpp || $DIALECT="no"
if test $DILAECT = no; then
AC_MSG_ERROR([c++ compiler does not support c++14])
else
echo $DILAECT
fi
Upvotes: 1
Reputation:
What you're looking for has already been made as AX_CXX_COMPILE_STDCXX_11
, part of autoconf-archive. It will add the required option to the environment (formerly through CXXFLAGS
, now through CXX
) and error out if no C++11 support is available.
Upvotes: 31