[build] Fix CMake protobuf dependency handling (#6772)

Reverts #6609 since that fix didn't Just Work(tm) on Windows. (edit: or Ubuntu. Seems to have broken everything except macOS.) This PR configures CMake to try and find protobuf-config.cmake first, which allows protobuf to pull in abseil for us. If protobuf-config.cmake is not available (coprocessors which don't have a new enough protobuf installed are a common case), it will fallback to CMake's built-in FindProtobuf module, which is what we were using before.

Add wpi::CreateMessage, a wrapper with an ifdef to switch between Arena::CreateMessage and Arena::Create, since the former is deprecated in newer versions of protobuf. This allows forward compatibility with newer versions of protobuf.
This commit is contained in:
Gold856
2024-06-28 09:28:39 -04:00
committed by GitHub
parent a7173dbd3c
commit 5ce72d43e4
33 changed files with 114 additions and 62 deletions

View File

@@ -10,6 +10,7 @@
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/message.h>
#include "wpi/ProtoHelper.h"
#include "wpi/SmallVector.h"
using namespace wpi;
@@ -170,7 +171,7 @@ static void ForEachProtobufDescriptorImpl(
descproto);
}
if (!*descproto) {
*descproto = Arena::CreateMessage<FileDescriptorProto>(arena);
*descproto = wpi::CreateMessage<FileDescriptorProto>(arena);
}
(*descproto)->Clear();
desc->CopyTo(*descproto);

View File

@@ -6,6 +6,8 @@
#include <google/protobuf/descriptor.h>
#include "wpi/ProtoHelper.h"
using namespace wpi;
using google::protobuf::Arena;
@@ -34,7 +36,7 @@ bool ProtobufMessageDatabase::Add(std::string_view filename,
if (!file.proto) {
file.proto = std::unique_ptr<FileDescriptorProto>{
Arena::CreateMessage<FileDescriptorProto>(nullptr)};
wpi::CreateMessage<FileDescriptorProto>(nullptr)};
} else {
// replacing an existing one; remove any previously existing refs
for (auto&& dep : file.proto->dependency()) {