configure: Add test for whether protoc matches protobuf

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2019-06-12 18:43:54 -07:00
parent feced5910c
commit 0cc492dbae
+18
View File
@@ -489,6 +489,24 @@ AS_IF([test "$enable_static_protobuf" = yes],
AS_IF([test "$enable_static_libgcc" = yes],
[AC_MSG_ERROR([--enable-static-libgcc requires --enable-static-protobuf])])])
AC_MSG_CHECKING([whether protoc matches protobuf])
cat > conftest.proto <<'EOF'
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
EOF
AS_IF([$PROTOC --cpp_out=. conftest.proto],
[old_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $protobuf_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "conftest.pb.h"]], [[]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
cat conftest.err
AC_MSG_FAILURE([Could not build output generated by protoc ($PROTOC).
Check that protoc matches the installed protobuf headers and libraries.])])
CPPFLAGS="$old_CPPFLAGS"],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([Could not run protoc ($PROTOC).])])
# Bash completion needs to ask where it goes if >= 2.0 is installed.
AS_IF([test "$install_completion" != no],
[PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],