c++11: improve configure.
* configure.ac, m4/ax_check_compile_flag.m4: Update from Vaucanson 2. (Thank you Akim.)
This commit is contained in:
parent
ea6a34b0b4
commit
3a406dc3d7
2 changed files with 18 additions and 32 deletions
44
configure.ac
44
configure.ac
|
|
@ -72,26 +72,11 @@ AX_CHECK_COMPILE_FLAG([-Werror -fvisibility=hidden],
|
||||||
CXXFLAGS="$CXXFLAGS -DSPOT_BUILD"
|
CXXFLAGS="$CXXFLAGS -DSPOT_BUILD"
|
||||||
|
|
||||||
# Turn on C++11 support
|
# Turn on C++11 support
|
||||||
AX_CHECK_COMPILE_FLAG([-std=c++11 -stdlib=libc++],
|
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody],
|
||||||
[CXXFLAGS="$CXXFLAGS -std=c++11 -stdlib=libc++"
|
[AC_LANG_SOURCE([#include <memory>
|
||||||
stdpass=true])
|
#include <string>
|
||||||
if ! "${stdpass-false}"; then
|
|
||||||
AX_CHECK_COMPILE_FLAG([-std=c++11],
|
|
||||||
[CXXFLAGS="$CXXFLAGS -std=c++11"
|
|
||||||
stdpass=true])
|
|
||||||
fi
|
|
||||||
if ! "${stdpass-false}"; then
|
|
||||||
AX_CHECK_COMPILE_FLAG([-std=c++0x],
|
|
||||||
[CXXFLAGS="$CXXFLAGS -std=c++0x"
|
|
||||||
stdpass=true])
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! "${stdpass-false}"; then
|
template <typename T>
|
||||||
AC_ERROR([unable to turn on C++11 mode with this compiler])
|
|
||||||
fi
|
|
||||||
|
|
||||||
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
|
|
||||||
template <typename T>
|
|
||||||
struct check
|
struct check
|
||||||
{
|
{
|
||||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||||
|
|
@ -99,6 +84,8 @@ m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
|
||||||
|
|
||||||
typedef check<check<bool>> right_angle_brackets;
|
typedef check<check<bool>> right_angle_brackets;
|
||||||
|
|
||||||
|
auto f = std::make_shared<std::string>("shared_ptr");
|
||||||
|
|
||||||
int a;
|
int a;
|
||||||
decltype(a) b;
|
decltype(a) b;
|
||||||
|
|
||||||
|
|
@ -107,16 +94,17 @@ m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
|
||||||
check_type&& cr = static_cast<check_type&&>(c);
|
check_type&& cr = static_cast<check_type&&>(c);
|
||||||
|
|
||||||
auto d = a;
|
auto d = a;
|
||||||
])
|
])])
|
||||||
|
|
||||||
AC_CACHE_CHECK([whether $CXX $CXXFLAGS supports C++11 features],
|
for f in -std=c++11 '-std=c++11 -stdlib=libc++' -std=c++0x
|
||||||
[ax_cv_cxx_compile_cxx11],
|
do
|
||||||
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
AX_CHECK_COMPILE_FLAG([$f], [CXXFLAGS="$CXXFLAGS $f" stdpass=true], [], [],
|
||||||
[ax_cv_cxx_compile_cxx11=yes],
|
[_AX_CXX_COMPILE_STDCXX_11_testbody])
|
||||||
[ax_cv_cxx_compile_cxx11=no])])
|
${stdpass-false} && break
|
||||||
|
done
|
||||||
test "x$ax_cv_cxx_compile_cxx11" = xyes ||
|
if ! "${stdpass-false}"; then
|
||||||
AC_ERROR([unable to compile C++11 with this compiler])
|
AC_ERROR([unable to turn on C++11 mode with this compiler])
|
||||||
|
fi
|
||||||
|
|
||||||
AX_CHECK_BUDDY
|
AX_CHECK_BUDDY
|
||||||
AX_CHECK_GSPNLIB
|
AX_CHECK_GSPNLIB
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,10 @@ AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
|
||||||
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
|
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
|
||||||
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
||||||
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
|
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
|
AC_COMPILE_IFELSE([m4_default([$5], [AC_LANG_PROGRAM()])],
|
||||||
[AS_VAR_SET(CACHEVAR,[yes])],
|
[AS_VAR_SET(CACHEVAR,[yes])],
|
||||||
[AS_VAR_SET(CACHEVAR,[no])])
|
[AS_VAR_SET(CACHEVAR,[no])])
|
||||||
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
|
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
|
||||||
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
|
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], [$2], [$3])
|
||||||
[m4_default([$2], :)],
|
|
||||||
[m4_default([$3], :)])
|
|
||||||
AS_VAR_POPDEF([CACHEVAR])dnl
|
AS_VAR_POPDEF([CACHEVAR])dnl
|
||||||
])dnl AX_CHECK_COMPILE_FLAGS
|
])dnl AX_CHECK_COMPILE_FLAGS
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue