Skip to content

Commit 1b4adae

Browse files
committed
Fix build failure with the Protobuf 23.3
### Motivation The current CMakeLists.txt does not work with the latest Protobuf (23.3.0). It's because currently the Module mode is used to find Protobuf, while the `FindProtobuf.cmake` is not updated to find the Abseil dependency. See protocolbuffers/protobuf#12292 (comment) ### Modifications For macOS, use the Config mode to find Protobuf. It's because in other systems, the Module mode works well. Besides, enable `PROTOBUF_USE_DLLS` as a workaround for protocolbuffers/protobuf#12983 is not released.
1 parent 0202218 commit 1b4adae

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

.github/workflows/ci-pr-validation.yaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,10 @@ jobs:
5050
- name: Install deps (macOS)
5151
if: ${{ startsWith(matrix.os, 'macos') }}
5252
run: |
53-
# Install protobuf v21.12
54-
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/2d47ed2eac09d59ffc2c92b1d804f1c232188c88/Formula/protobuf.rb
55-
brew install --formula ./protobuf.rb
56-
brew install pkg-config wireshark
57-
53+
brew install pkg-config wireshark protobuf
5854
- name: Build wireshark plugin
5955
run: |
60-
cmake -S wireshark -B build-wireshark
56+
cmake -S wireshark -B build-wireshark -DCMAKE_CXX_STANDARD=17
6157
cmake --build build-wireshark
6258
6359
unit-tests:
@@ -270,19 +266,15 @@ jobs:
270266
uses: actions/checkout@v3
271267

272268
- name: Install dependencies
273-
run: |
274-
# Install protobuf v21.12
275-
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/2d47ed2eac09d59ffc2c92b1d804f1c232188c88/Formula/protobuf.rb
276-
brew install --formula ./protobuf.rb
277-
brew install openssl boost zstd snappy googletest
269+
run: brew install openssl protobuf boost zstd snappy googletest
278270

279271
- name: Configure (default)
280272
shell: bash
281273
run: |
282-
# The latest GTest requires C++14
274+
# The latest Protobuf requires C++17
283275
cmake \
284276
-B ./build-macos \
285-
-DCMAKE_CXX_STANDARD=14 \
277+
-DCMAKE_CXX_STANDARD=17 \
286278
-S .
287279
288280
- name: Compile

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ find_package(OpenSSL REQUIRED)
135135
message("OPENSSL_INCLUDE_DIR: " ${OPENSSL_INCLUDE_DIR})
136136
message("OPENSSL_LIBRARIES: " ${OPENSSL_LIBRARIES})
137137

138-
find_package(Protobuf REQUIRED)
138+
if (APPLE)
139+
# See https://github.com/apache/arrow/issues/35987
140+
add_definitions(-DPROTOBUF_USE_DLLS)
141+
find_package(Protobuf REQUIRED CONFIG)
142+
else ()
143+
find_package(Protobuf REQUIRED)
144+
endif ()
139145
message("Protobuf_INCLUDE_DIRS: " ${Protobuf_INCLUDE_DIRS})
140146
message("Protobuf_LIBRARIES: " ${Protobuf_LIBRARIES})
141147

@@ -173,7 +179,7 @@ if (LINK_STATIC AND NOT VCPKG_TRIPLET)
173179
add_definitions(-DCURL_STATICLIB)
174180
endif()
175181
elseif (LINK_STATIC AND VCPKG_TRIPLET)
176-
find_package(protobuf REQUIRED)
182+
find_package(Protobuf REQUIRED)
177183
message(STATUS "Found protobuf static library: " ${Protobuf_LIBRARIES})
178184
if (MSVC AND (${CMAKE_BUILD_TYPE} STREQUAL Debug))
179185
find_library(ZLIB_LIBRARIES NAMES zlibd)
@@ -296,7 +302,7 @@ set(COMMON_LIBS
296302
${Boost_REGEX_LIBRARY}
297303
${Boost_SYSTEM_LIBRARY}
298304
${Boost_DATE_TIME_LIBRARY}
299-
${Protobuf_LIBRARIES}
305+
protobuf::libprotobuf
300306
${CURL_LIBRARIES}
301307
${OPENSSL_LIBRARIES}
302308
${ZLIB_LIBRARIES}

wireshark/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
cmake_minimum_required(VERSION 3.7)
2121
project(pulsar-cpp-wireshark)
2222

23-
set(CMAKE_CXX_STANDARD 11)
23+
if (NOT CMAKE_CXX_STANDARD)
24+
set(CMAKE_CXX_STANDARD 11)
25+
endif ()
2426

2527
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
2628
execute_process(COMMAND sh -c "find $(brew --prefix)/Cellar/wireshark -name 'include' -type d"
@@ -45,7 +47,12 @@ pkg_check_modules(GLIB glib-2.0)
4547
MESSAGE(STATUS "Use WIRESHARK_INCLUDE_PATH: ${WIRESHARK_INCLUDE_PATH}")
4648
MESSAGE(STATUS "Use GLIB_INCLUDE_DIRS: ${GLIB_INCLUDE_DIRS}")
4749

48-
find_package(Protobuf REQUIRED)
50+
set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "")
51+
if (APPLE)
52+
find_package(Protobuf REQUIRED CONFIG)
53+
else ()
54+
find_package(Protobuf REQUIRED)
55+
endif ()
4956

5057
set(PROTO_SOURCES PulsarApi.pb.cc)
5158
protobuf_generate_cpp(${PROTO_SOURCES}

wireshark/pulsarDissector.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ constexpr int kWiresharkMinorVersion = VERSION_MINOR;
3434
#include <glib.h>
3535
#include <wsutil/nstime.h>
3636

37+
#include <map>
38+
3739
#include "PulsarApi.pb.h"
3840

3941
#ifdef VERSION

0 commit comments

Comments
 (0)