allow c++14

master
Marc Wäckerlin 8 years ago
parent 126404115a
commit 38960f8635
  1. 82
      ax_cxx_compile_stdcxx_11.m4
  2. 98
      scripts/ax_cxx_compile_stdcxx_11.m4
  3. 4
      scripts/ax_init_standard_project.m4

@ -5,11 +5,13 @@
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
# AX_CXX_COMPILE_STDCXX_14([ext|noext],[mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXXFLAGS to enable support.
# or C++14 standard; if necessary, add switches to CXXFLAGS to
# enable support.
#
# The first argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
@ -131,3 +133,81 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
AC_SUBST(HAVE_CXX11)
fi
])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_14], [dnl
m4_if([$1], [], [],
[$1], [ext], [],
[$1], [noext], [],
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_14])])dnl
m4_if([$2], [], [ax_cxx_compile_cxx14_required=true],
[$2], [mandatory], [ax_cxx_compile_cxx14_required=true],
[$2], [optional], [ax_cxx_compile_cxx14_required=false],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_14])])dnl
AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++14 features by default,
ax_cv_cxx_compile_cxx14,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[ax_cv_cxx_compile_cxx14=yes],
[ax_cv_cxx_compile_cxx14=no])])
if test x$ax_cv_cxx_compile_cxx14 = xyes; then
ac_success=yes
fi
m4_if([$1], [noext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=gnu++14 -std=gnu++0y; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx14_$switch])
AC_CACHE_CHECK(whether $CXX supports C++14 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
m4_if([$1], [ext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=c++14 -std=c++0y; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx14_$switch])
AC_CACHE_CHECK(whether $CXX supports C++14 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx14_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++14 language features is required.])
fi
else
if test x$ac_success = xno; then
HAVE_CXX14=0
AC_MSG_NOTICE([No compiler with C++14 support was found])
else
HAVE_CXX14=1
AC_DEFINE(HAVE_CXX14,1,
[define if the compiler supports basic C++14 syntax])
fi
AC_SUBST(HAVE_CXX14)
fi
])

@ -4,12 +4,16 @@
#
# SYNOPSIS
#
# AX_REQUIRE_STDCXX_11
# AX_REQUIRE_STDCXX_14
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
# AX_CXX_COMPILE_STDCXX_14([ext|noext],[mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXXFLAGS to enable support.
# or C++14 standard; if necessary, add switches to CXXFLAGS to
# enable support.
#
# The first argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
@ -131,3 +135,95 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
AC_SUBST(HAVE_CXX11)
fi
])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_14], [dnl
m4_if([$1], [], [],
[$1], [ext], [],
[$1], [noext], [],
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_14])])dnl
m4_if([$2], [], [ax_cxx_compile_cxx14_required=true],
[$2], [mandatory], [ax_cxx_compile_cxx14_required=true],
[$2], [optional], [ax_cxx_compile_cxx14_required=false],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_14])])dnl
AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++14 features by default,
ax_cv_cxx_compile_cxx14,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[ax_cv_cxx_compile_cxx14=yes],
[ax_cv_cxx_compile_cxx14=no])])
if test x$ax_cv_cxx_compile_cxx14 = xyes; then
ac_success=yes
fi
m4_if([$1], [noext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=gnu++14 -std=gnu++0y; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx14_$switch])
AC_CACHE_CHECK(whether $CXX supports C++14 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
m4_if([$1], [ext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=c++14 -std=c++0y; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx14_$switch])
AC_CACHE_CHECK(whether $CXX supports C++14 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx14_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++14 language features is required.])
fi
else
HAVE_CXX11=${HAVE_CXX14}
if test x$ac_success = xno; then
HAVE_CXX14=0
AC_MSG_NOTICE([No compiler with C++14 support was found])
AX_CXX_COMPILE_STDCXX_11([$1], [optional])
else
HAVE_CXX14=1
AC_DEFINE(HAVE_CXX14,1,
[define if the compiler supports basic C++14 syntax])
fi
AC_SUBST(HAVE_CXX11)
AC_SUBST(HAVE_CXX14)
fi
])
AC_DEFUN([AX_REQUIRE_STDCXX_11], [
if test x${HAVE_CXX11} != x1; then
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
fi
])
AC_DEFUN([AX_REQUIRE_STDCXX_14], [
if test x${HAVE_CXX14} != x1; then
AC_MSG_ERROR([*** A compiler with support for C++14 language features is required.])
fi
])

@ -129,7 +129,7 @@ AC_DEFUN([AX_SUBST], [
# m4_define(x_minor, MINOR_NUMBER) # project's minor version
# m4_include(ax_init_standard_project.m4)
# AC_INIT(x_package_name, x_version, x_bugreport, x_package_name)
# AM_INIT_AUTOMAKE([1.9 tar-pax])
# AM_INIT_AUTOMAKE([1.9 tar-pax parallel-tests color-tests])
# AX_INIT_STANDARD_PROJECT
#
# you change nothing but: YOUR_PACKAGE_NAME, MAJOR_NUMBER, MINOR_NUMBER
@ -273,7 +273,7 @@ EOF
AC_DEFUN([AX_USE_CXX], [
m4_include(ax_cxx_compile_stdcxx_11.m4)
AC_LANG(C++)
AX_CXX_COMPILE_STDCXX_11(noext, optional)
AX_CXX_COMPILE_STDCXX_14(noext, optional)
AC_PROG_CXX
AC_PROG_CPP

Loading…
Cancel
Save