mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[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:
@@ -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);
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user