2015-03-24 15:47:17 +00:00
|
|
|
AC_DEFUN([AX_CXX_STD_CXX_FLAG],[
|
2019-05-18 15:12:27 +00:00
|
|
|
AC_CACHE_CHECK([for support for the "-std=c++17" flag], [ax_cv_std_cxx_flag],[
|
2011-10-21 19:40:49 +00:00
|
|
|
|
|
|
|
AC_LANG_PUSH(C++)
|
2015-03-24 15:47:17 +00:00
|
|
|
CXXFLAGS_SAVED="$CXXFLAGS"
|
|
|
|
|
2020-05-13 14:34:37 +00:00
|
|
|
for flag in c++17; do
|
2015-06-06 07:30:10 +00:00
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED -std=$flag"
|
|
|
|
AC_TRY_COMPILE([], [true;], [ax_cv_std_cxx_flag="-std=$flag"], [ax_cv_std_cxx_flag="undecided"])
|
2011-10-21 19:40:49 +00:00
|
|
|
|
2015-06-06 07:30:10 +00:00
|
|
|
if test x"$ax_cv_std_cxx_flag" != xundecided ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2013-10-26 16:50:15 +00:00
|
|
|
|
2015-03-24 15:47:17 +00:00
|
|
|
if test x"$ax_cv_std_cxx_flag" = xundecided ; then
|
2015-06-06 07:30:10 +00:00
|
|
|
ax_cv_std_cxx_flag="no"
|
2013-10-26 16:50:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
AC_LANG_POP
|
2011-10-21 19:40:49 +00:00
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED"
|
|
|
|
])
|
|
|
|
|
2015-03-24 15:47:17 +00:00
|
|
|
STD_CXX=""
|
|
|
|
if test x"$ax_cv_std_cxx_flag" != xno ; then
|
|
|
|
STD_CXX=$ax_cv_std_cxx_flag
|
2011-10-21 19:40:49 +00:00
|
|
|
fi
|
2013-10-26 16:50:15 +00:00
|
|
|
|
2015-03-24 15:47:17 +00:00
|
|
|
AC_SUBST(STD_CXX)
|
2011-10-21 19:40:49 +00:00
|
|
|
])
|
|
|
|
|
2019-10-13 11:40:19 +00:00
|
|
|
AC_DEFUN([AX_CXX17_ATTRIBUTE_MAYBE_UNUSED],[
|
|
|
|
AC_CACHE_CHECK([for support for C++17 feature "attribute 'maybe_unused'"], [ax_cv_cxx17_attribute_maybe_unused],[
|
|
|
|
|
|
|
|
CXXFLAGS_SAVED=$CXXFLAGS
|
|
|
|
CXXFLAGS="$CXXFLAGS $STD_CXX"
|
|
|
|
export CXXFLAGS
|
|
|
|
|
|
|
|
AC_LANG_PUSH(C++)
|
|
|
|
AC_TRY_COMPILE(
|
|
|
|
[
|
|
|
|
int testme([[maybe_unused]] int the_var) {
|
|
|
|
return 42;
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[return testme(54);],
|
|
|
|
[ax_cv_cxx17_attribute_maybe_unused="yes"],
|
|
|
|
[ax_cv_cxx17_attribute_maybe_unused="no"])
|
|
|
|
AC_LANG_POP
|
|
|
|
|
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED"
|
|
|
|
])
|
|
|
|
|
|
|
|
if ! test x"$ax_cv_cxx17_attribute_maybe_unused" = xyes ; then
|
|
|
|
missing_cxx_features="$missing_cxx_features\n * attribute 'maybe_unused' (C++17)"
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_DEFUN([AX_CXX17_STRUCTURED_BINDINGS],[
|
|
|
|
AC_CACHE_CHECK([for support for C++17 feature "structured bindings"], [ax_cv_cxx17_structured_bindings],[
|
|
|
|
|
|
|
|
CXXFLAGS_SAVED=$CXXFLAGS
|
|
|
|
CXXFLAGS="$CXXFLAGS $STD_CXX"
|
|
|
|
export CXXFLAGS
|
|
|
|
|
|
|
|
AC_LANG_PUSH(C++)
|
|
|
|
AC_TRY_COMPILE(
|
|
|
|
[
|
|
|
|
#include <utility>
|
|
|
|
std::pair<int, char> testme() {
|
|
|
|
return std::make_pair(42, '!');
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
auto const &[the_int, the_char] = testme();
|
|
|
|
return the_int;
|
|
|
|
],
|
|
|
|
[ax_cv_cxx17_structured_bindings="yes"],
|
|
|
|
[ax_cv_cxx17_structured_bindings="no"])
|
|
|
|
AC_LANG_POP
|
|
|
|
|
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED"
|
|
|
|
])
|
|
|
|
|
|
|
|
if ! test x"$ax_cv_cxx17_structured_bindings" = xyes ; then
|
|
|
|
missing_cxx_features="$missing_cxx_features\n * structured bindings (C++17)"
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
2019-10-31 17:18:02 +00:00
|
|
|
AC_DEFUN([AX_CXX17_NESTED_NAMESPACE_DEFINITION],[
|
|
|
|
AC_CACHE_CHECK([for support for C++17 feature "nested namespace definition"], [ax_cv_cxx17_nested_namespace_definition],[
|
|
|
|
|
|
|
|
CXXFLAGS_SAVED=$CXXFLAGS
|
|
|
|
CXXFLAGS="$CXXFLAGS $STD_CXX"
|
|
|
|
export CXXFLAGS
|
|
|
|
|
|
|
|
AC_LANG_PUSH(C++)
|
|
|
|
AC_TRY_COMPILE(
|
|
|
|
[namespace A::B::C { int d; }],
|
|
|
|
[A::B::C::d = 1; return A::B::C::d;],
|
|
|
|
[ax_cv_cxx17_nested_namespace_definition="yes"],
|
|
|
|
[ax_cv_cxx17_nested_namespace_definition="no"])
|
|
|
|
AC_LANG_POP
|
|
|
|
|
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED"
|
|
|
|
])
|
|
|
|
|
|
|
|
if ! test x"$ax_cv_cxx17_nested_namespace_definition" = xyes ; then
|
|
|
|
missing_cxx_features="$missing_cxx_features\n * nested namespace definition (C++17)"
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
2019-12-30 20:32:49 +00:00
|
|
|
AC_DEFUN([AX_CXX17_STD_OPTIONAL],[
|
|
|
|
AC_CACHE_CHECK([for support for C++17 feature "std::optional"], [ax_cv_cxx17_std_optional],[
|
|
|
|
|
|
|
|
CXXFLAGS_SAVED=$CXXFLAGS
|
|
|
|
CXXFLAGS="$CXXFLAGS $STD_CXX"
|
|
|
|
export CXXFLAGS
|
|
|
|
|
|
|
|
AC_LANG_PUSH(C++)
|
|
|
|
AC_TRY_COMPILE(
|
|
|
|
[#include <optional>],
|
|
|
|
[
|
|
|
|
std::optional<int> moo;
|
|
|
|
moo = 42;
|
2019-12-31 15:08:55 +00:00
|
|
|
return moo ? moo.value() : moo.value_or(54);
|
2019-12-30 20:32:49 +00:00
|
|
|
],
|
|
|
|
[ax_cv_cxx17_std_optional="yes"],
|
|
|
|
[ax_cv_cxx17_std_optional="no"])
|
|
|
|
AC_LANG_POP
|
|
|
|
|
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED"
|
|
|
|
])
|
|
|
|
|
|
|
|
if ! test x"$ax_cv_cxx17_std_optional" = xyes ; then
|
|
|
|
missing_cxx_features="$missing_cxx_features\n * std::optional (C++17)"
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
2020-05-12 16:12:28 +00:00
|
|
|
AC_DEFUN([AX_CXX17_STD_GCD],[
|
|
|
|
AC_CACHE_CHECK([for support for C++17 feature "std::gcd"], [ax_cv_cxx17_std_gcd],[
|
|
|
|
|
|
|
|
CXXFLAGS_SAVED=$CXXFLAGS
|
|
|
|
CXXFLAGS="$CXXFLAGS $STD_CXX"
|
|
|
|
export CXXFLAGS
|
|
|
|
|
|
|
|
AC_LANG_PUSH(C++)
|
|
|
|
AC_TRY_COMPILE(
|
|
|
|
[#include <numeric>],
|
|
|
|
[return std::gcd(42, 54);],
|
|
|
|
[ax_cv_cxx17_std_gcd="yes"],
|
|
|
|
[ax_cv_cxx17_std_gcd="no"])
|
|
|
|
AC_LANG_POP
|
|
|
|
|
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED"
|
|
|
|
])
|
|
|
|
|
|
|
|
if ! test x"$ax_cv_cxx17_std_gcd" = xyes ; then
|
|
|
|
missing_cxx_features="$missing_cxx_features\n * std::gcd (C++17)"
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
2020-05-13 14:34:17 +00:00
|
|
|
AC_DEFUN([AX_CXX17_CONSTEXPR_IF],[
|
|
|
|
AC_CACHE_CHECK([for support for C++17 feature "constexpr if"], [ax_cv_cxx17_constexpr_if],[
|
|
|
|
|
|
|
|
CXXFLAGS_SAVED=$CXXFLAGS
|
|
|
|
CXXFLAGS="$CXXFLAGS $STD_CXX"
|
|
|
|
export CXXFLAGS
|
|
|
|
|
|
|
|
AC_LANG_PUSH(C++)
|
|
|
|
AC_TRY_COMPILE(
|
|
|
|
[],
|
|
|
|
[if constexpr (true) return 42; else return 54;],
|
|
|
|
[ax_cv_cxx17_constexpr_if="yes"],
|
|
|
|
[ax_cv_cxx17_constexpr_if="no"])
|
|
|
|
AC_LANG_POP
|
|
|
|
|
|
|
|
CXXFLAGS="$CXXFLAGS_SAVED"
|
|
|
|
])
|
|
|
|
|
|
|
|
if ! test x"$ax_cv_cxx17_constexpr_if" = xyes ; then
|
|
|
|
missing_cxx_features="$missing_cxx_features\n * constexpr if (C++17)"
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
2020-05-12 16:12:28 +00:00
|
|
|
dnl AC_DEFUN([AX_CXX17_DEF_NAME],[
|
2019-10-13 11:40:19 +00:00
|
|
|
dnl AC_CACHE_CHECK([for support for C++17 feature "human"], [ax_cv_cxx17_def_name],[
|
2011-10-21 19:40:49 +00:00
|
|
|
dnl
|
|
|
|
dnl CXXFLAGS_SAVED=$CXXFLAGS
|
2015-03-24 15:47:17 +00:00
|
|
|
dnl CXXFLAGS="$CXXFLAGS $STD_CXX"
|
2011-10-21 19:40:49 +00:00
|
|
|
dnl export CXXFLAGS
|
|
|
|
dnl
|
|
|
|
dnl AC_LANG_PUSH(C++)
|
|
|
|
dnl AC_TRY_COMPILE(
|
|
|
|
dnl [],
|
|
|
|
dnl [],
|
2019-10-13 11:40:19 +00:00
|
|
|
dnl [ax_cv_cxx17_def_name="yes"],
|
|
|
|
dnl [ax_cv_cxx17_def_name="no"])
|
2011-10-21 19:40:49 +00:00
|
|
|
dnl AC_LANG_POP
|
|
|
|
dnl
|
|
|
|
dnl CXXFLAGS="$CXXFLAGS_SAVED"
|
|
|
|
dnl ])
|
|
|
|
dnl
|
2019-10-13 11:40:19 +00:00
|
|
|
dnl if ! test x"$ax_cv_cxx17_def_name" = xyes ; then
|
|
|
|
dnl missing_cxx_features="$missing_cxx_features\n * human (C++17)"
|
2011-10-21 19:40:49 +00:00
|
|
|
dnl fi
|
|
|
|
dnl ])
|
|
|
|
|
2015-03-24 15:47:17 +00:00
|
|
|
AX_CXX_STD_CXX_FLAG
|
2019-10-13 11:40:19 +00:00
|
|
|
AX_CXX17_ATTRIBUTE_MAYBE_UNUSED
|
2019-10-31 17:18:02 +00:00
|
|
|
AX_CXX17_NESTED_NAMESPACE_DEFINITION
|
2019-10-13 11:40:19 +00:00
|
|
|
AX_CXX17_STRUCTURED_BINDINGS
|
2019-12-30 20:32:49 +00:00
|
|
|
AX_CXX17_STD_OPTIONAL
|
2020-05-12 16:12:28 +00:00
|
|
|
AX_CXX17_STD_GCD
|
2020-05-13 14:34:17 +00:00
|
|
|
AX_CXX17_CONSTEXPR_IF
|
2011-10-21 19:40:49 +00:00
|
|
|
|
2015-03-24 15:47:17 +00:00
|
|
|
if test x"$missing_cxx_features" != x ; then
|
2020-05-13 14:34:37 +00:00
|
|
|
printf "The following features of the C++17 standards are not supported by $CXX:$missing_cxx_features\n"
|
2018-04-20 18:03:57 +00:00
|
|
|
printf "If you are using the GNU C compiler collection (gcc), you need\n"
|
2019-12-30 20:32:49 +00:00
|
|
|
printf "at least v7; for clang v4 and newer should work.\n"
|
2020-05-13 14:34:37 +00:00
|
|
|
AC_MSG_ERROR([support for required C++17 features incomplete])
|
2011-10-21 19:40:49 +00:00
|
|
|
fi
|