configure.ac: Require C++17 when building against protobuf >= 4.22.0

It's unclear from looking at the online protobuf documentation whether
C++14 or C++17 is now required when building against newer versions of
protobuf (or perhaps I'm looking in the wrong place), but experimentally
it did not work for me with C++14.

This commit rewrites the versioned PKG_CHECK_MODULES checks in
configure.ac to enforce the following policies:

 * Require protobuf >= 2.6.0.
 * On protobuf >= 3.0.0, require C++11.
 * On protobuf >= 4.22.0, require C++17.
This commit is contained in:
Robert Edmonds 2023-07-02 19:48:17 -04:00
parent 8d334a7204
commit 23d2246e0f

View File

@ -76,12 +76,26 @@ AC_ARG_ENABLE([protoc],
if test "x$enable_protoc" != "xno"; then if test "x$enable_protoc" != "xno"; then
AC_LANG_PUSH([C++]) AC_LANG_PUSH([C++])
AX_CXX_COMPILE_STDCXX(11, noext, mandatory) # PKG_CHECK_MODULES(prefix, list-of-modules, action-if-found, action-if-not-found)
PKG_CHECK_MODULES(
PKG_CHECK_MODULES([protobuf], [protobuf >= 3.0.0], [protobuf],
[proto3_supported=yes], [protobuf >= 4.22.0],
[PKG_CHECK_MODULES([protobuf], [protobuf >= 2.6.0])] [
) proto3_supported=yes
AX_CXX_COMPILE_STDCXX(17, noext, mandatory)
],
[
PKG_CHECK_MODULES(
[protobuf],
[protobuf >= 3.0.0],
[
proto3_supported=yes
AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
],
[
PKG_CHECK_MODULES([protobuf], [protobuf >= 2.6.0])
])
])
save_CPPFLAGS="$CPPFLAGS" save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$save_CPPFLAGS $protobuf_CFLAGS" CPPFLAGS="$save_CPPFLAGS $protobuf_CFLAGS"