From 71042619cce74ff104b61ad2a35f6c22997baecf Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Mon, 15 May 2023 14:54:11 -0700 Subject: [PATCH] Add a check for minimum supported Abseil version. PiperOrigin-RevId: 532235063 --- src/google/protobuf/port_def.inc | 15 +++++++++++++++ src/google/protobuf/port_undef.inc | 1 + 2 files changed, 16 insertions(+) diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index c43aab0ab1..01cff18e77 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -209,6 +209,21 @@ static_assert(PROTOBUF_MSC_VER_MIN(1910), "Protobuf only supports MSVC 2017 and #endif static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and newer."); +// Check minimum Abseil version. +#if defined(ABSL_LTS_RELEASE_VERSION) && defined(ABSL_LTS_RELEASE_PATCH_LEVEL) +#define PROTOBUF_ABSL_MIN(x, y) \ + (ABSL_LTS_RELEASE_VERSION > (x) || \ + (ABSL_LTS_RELEASE_VERSION == (x) && ABSL_LTS_RELEASE_PATCH_LEVEL >= (y))) +#else +// If we can't find an Abseil version, it's either not installed at all (which +// should trigger cmake errors), using a non-LTS release, or just isn't used in +// this file. +#define PROTOBUF_ABSL_MIN(x, y) 1 +#endif + +static_assert(PROTOBUF_ABSL_MIN(20230125, 3), + "Protobuf only supports Abseil version 20230125.3 and newer."); + // Future versions of protobuf will include breaking changes to some APIs. // This macro can be set to enable these API changes ahead of time, so that // user code can be updated before upgrading versions of protobuf. diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index 89bf2f2034..b377715c82 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -48,6 +48,7 @@ #undef PROTOBUF_CLANG_MIN #undef PROTOBUF_MSC_VER_MIN #undef PROTOBUF_CPLUSPLUS_MIN +#undef PROTOBUF_ABSL_MIN #undef PROTOBUF_ALWAYS_INLINE #undef PROTOBUF_ALWAYS_INLINE_CALL #undef PROTOBUF_NDEBUG_INLINE