summaryrefslogtreecommitdiff
path: root/net-libs/ignition-transport/files/protobuf.patch
blob: 497da899db7afb65e78ccb4b346bdc9cf7b4e03e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From e35a697b619dbcecec0ae0c8b8f0a644d368abf3 Mon Sep 17 00:00:00 2001
From: Silvio Traversaro <silvio@traversaro.it>
Date: Tue, 6 Jun 2023 17:19:49 +0200
Subject: [PATCH] Fix compatibility with protobuf 22

Signed-off-by: Silvio Traversaro <silvio@traversaro.it>
---
 CMakeLists.txt                              | 2 --
 include/gz/transport/RepHandler.hh          | 8 ++++++--
 include/gz/transport/SubscriptionHandler.hh | 6 ++++--
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e3aab859..843fb17cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,9 +38,7 @@ message(STATUS "\n\n-- ====== Finding Dependencies ======")
 
 #--------------------------------------
 # Find Protobuf
-set(REQ_PROTOBUF_VER 3)
 ign_find_package(IgnProtobuf
-                 VERSION ${REQ_PROTOBUF_VER}
                  REQUIRED
                  PRETTY Protobuf)
 
diff --git a/include/gz/transport/RepHandler.hh b/include/gz/transport/RepHandler.hh
index 5d27f98c1..a5675fca7 100644
--- a/include/gz/transport/RepHandler.hh
+++ b/include/gz/transport/RepHandler.hh
@@ -26,7 +26,7 @@
 #pragma warning(pop)
 #endif
 
-#if GOOGLE_PROTOBUF_VERSION > 2999999
+#if GOOGLE_PROTOBUF_VERSION > 2999999 && GOOGLE_PROTOBUF_VERSION < 4022000
 #include <google/protobuf/stubs/casts.h>
 #endif
 
@@ -140,7 +140,11 @@ namespace ignition
           return false;
         }
 
-#if GOOGLE_PROTOBUF_VERSION > 2999999
+#if GOOGLE_PROTOBUF_VERSION >= 4022000
+        auto msgReq =
+          google::protobuf::internal::DownCast<const Req*>(&_msgReq);
+        auto msgRep = google::protobuf::internal::DownCast<Rep*>(&_msgRep);
+#elif GOOGLE_PROTOBUF_VERSION > 2999999
         auto msgReq = google::protobuf::down_cast<const Req*>(&_msgReq);
         auto msgRep = google::protobuf::down_cast<Rep*>(&_msgRep);
 #else
diff --git a/include/gz/transport/SubscriptionHandler.hh b/include/gz/transport/SubscriptionHandler.hh
index 78477add0..d69c83ddb 100644
--- a/include/gz/transport/SubscriptionHandler.hh
+++ b/include/gz/transport/SubscriptionHandler.hh
@@ -28,7 +28,7 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION >= 3000000
+#if GOOGLE_PROTOBUF_VERSION >= 3000000 && GOOGLE_PROTOBUF_VERSION < 4022000
 #include <google/protobuf/stubs/casts.h>
 #endif
 
@@ -211,7 +211,9 @@ namespace ignition
         if (!this->UpdateThrottling())
           return true;
 
-#if GOOGLE_PROTOBUF_VERSION >= 3000000
+#if GOOGLE_PROTOBUF_VERSION >= 4022000
+        auto msgPtr = google::protobuf::internal::DownCast<const T*>(&_msg);
+#elif GOOGLE_PROTOBUF_VERSION >= 3000000
         auto msgPtr = google::protobuf::down_cast<const T*>(&_msg);
 #else
         auto msgPtr = google::protobuf::internal::down_cast<const T*>(&_msg);