build: allow c++17 standard to be used for compilation

This will allow compiling with the c++17 standard, which on some
distributions (macOS, FreeBSD) is required when using system
dependencies.

The ./configure script will now allow specifying --enable-c++17 to
enable c++17. The default remains c++11, and c++14 also remains
available.
This commit is contained in:
Patrick Lodder 2024-06-20 10:28:12 -04:00
parent 5bbb1fa1d8
commit 4196748d27
No known key found for this signature in database
GPG Key ID: 7C523F5FBABE80E7

View File

@ -63,8 +63,19 @@ AC_ARG_ENABLE([c++14],
[use_cxx14=$enableval],
[use_cxx14=no])
dnl Require C++11 or C++14 compiler (no GNU extensions)
if test "x$use_cxx14" = xyes; then
AC_ARG_ENABLE([c++17],
[AS_HELP_STRING([--enable-c++17],
[enable compilation in c++17 mode (disabled by default)])],
[use_cxx17=$enableval],
[use_cxx17=no])
dnl Require either of C++ 17, 14 or 11 (default) compiler (no GNU extensions)
if test "x$use_cxx17" = xyes; then
if test "x$use_cxx14" = xyes; then
AC_MSG_ERROR("Both c++17 and c++14 are configured. Please configure only one standard")
fi
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory], [nodefault])
elif test "x$use_cxx14" = xyes; then
AX_CXX_COMPILE_STDCXX([14], [noext], [mandatory], [nodefault])
else
AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory], [nodefault])