Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions .github/workflows/ci-pr-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ jobs:
- name: Install deps (macOS)
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
# Install protobuf v21.12
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/2d47ed2eac09d59ffc2c92b1d804f1c232188c88/Formula/protobuf.rb
brew install --formula ./protobuf.rb
brew install pkg-config wireshark

brew install pkg-config wireshark protobuf
- name: Build wireshark plugin
run: |
cmake -S wireshark -B build-wireshark
Expand Down Expand Up @@ -270,20 +266,11 @@ jobs:
uses: actions/checkout@v3

- name: Install dependencies
run: |
# Install protobuf v21.12
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/2d47ed2eac09d59ffc2c92b1d804f1c232188c88/Formula/protobuf.rb
brew install --formula ./protobuf.rb
brew install openssl boost zstd snappy googletest
run: brew install openssl protobuf boost zstd snappy googletest

- name: Configure (default)
shell: bash
run: |
# The latest GTest requires C++14
cmake \
-B ./build-macos \
-DCMAKE_CXX_STANDARD=14 \
-S .
run: cmake -B ./build-macos -S .

- name: Compile
shell: bash
Expand Down
26 changes: 22 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ MESSAGE(STATUS "Threads library: " ${CMAKE_THREAD_LIBS_INIT})

set(Boost_NO_BOOST_CMAKE ON)
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
if (APPLE)
# The latest Protobuf dependency on macOS requires the C++17 support
set(CMAKE_CXX_STANDARD 17)
else ()
set(CMAKE_CXX_STANDARD 11)
endif ()
endif ()
set(CMAKE_C_STANDARD 11)

Expand Down Expand Up @@ -135,7 +140,14 @@ find_package(OpenSSL REQUIRED)
message("OPENSSL_INCLUDE_DIR: " ${OPENSSL_INCLUDE_DIR})
message("OPENSSL_LIBRARIES: " ${OPENSSL_LIBRARIES})

find_package(Protobuf REQUIRED)
if (APPLE)
# See https://github.com/apache/arrow/issues/35987
add_definitions(-DPROTOBUF_USE_DLLS)
# Use Config mode to avoid FindProtobuf.cmake does not find the Abseil library
find_package(Protobuf REQUIRED CONFIG)
else ()
find_package(Protobuf REQUIRED)
endif ()
message("Protobuf_INCLUDE_DIRS: " ${Protobuf_INCLUDE_DIRS})
message("Protobuf_LIBRARIES: " ${Protobuf_LIBRARIES})

Expand Down Expand Up @@ -173,7 +185,7 @@ if (LINK_STATIC AND NOT VCPKG_TRIPLET)
add_definitions(-DCURL_STATICLIB)
endif()
elseif (LINK_STATIC AND VCPKG_TRIPLET)
find_package(protobuf REQUIRED)
find_package(Protobuf REQUIRED)
message(STATUS "Found protobuf static library: " ${Protobuf_LIBRARIES})
if (MSVC AND (${CMAKE_BUILD_TYPE} STREQUAL Debug))
find_library(ZLIB_LIBRARIES NAMES zlibd)
Expand Down Expand Up @@ -296,14 +308,20 @@ set(COMMON_LIBS
${Boost_REGEX_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_DATE_TIME_LIBRARY}
${Protobuf_LIBRARIES}
${CURL_LIBRARIES}
${OPENSSL_LIBRARIES}
${ZLIB_LIBRARIES}
${ADDITIONAL_LIBRARIES}
${CMAKE_DL_LIBS}
)

if (APPLE)
# Protobuf_LIBRARIES is empty when finding Protobuf in Config mode
set(COMMON_LIBS ${COMMON_LIBS} protobuf::libprotobuf)
else ()
set(COMMON_LIBS ${COMMON_LIBS} ${Protobuf_LIBRARIES})
endif ()

if (MSVC)
set(COMMON_LIBS
${COMMON_LIBS}
Expand Down
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ The [dependencies.yaml](./dependencies.yaml) file provides the recommended depen
cmake . -DCMAKE_CXX_STANDARD=14
```

> **Note**:
>
> On macOS, the default C++ standard is 17 because the latest Protobuf from Homebrew requires the C++17 support.

## Platforms

Pulsar C++ Client Library has been tested on:
Expand Down Expand Up @@ -135,21 +139,14 @@ brew install cmake openssl protobuf boost googletest zstd snappy
#### Compile Pulsar client library:

```shell
cmake . -DCMAKE_CXX_STANDARD=14
make
```

You need to configure `CMAKE_CXX_STANDARD` with 14 because the latest `googletest` dependency from HomeBrew requires the C++14 support. If you don't want to build tests, you can run:

```bash
cmake . -DBUILD_TESTS=OFF
cmake .
make
```

If you want to build performance tools, you need to run:

```shell
cmake . -DBUILD_PERF_TOOLS=ON -DCMAKE_CXX_STANDARD=14
cmake . -DBUILD_PERF_TOOLS=ON
make
```

Expand Down
16 changes: 14 additions & 2 deletions wireshark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
cmake_minimum_required(VERSION 3.7)
project(pulsar-cpp-wireshark)

set(CMAKE_CXX_STANDARD 11)
if (NOT CMAKE_CXX_STANDARD)
if (APPLE)
# The latest Protobuf dependency on macOS requires the C++17 support
set(CMAKE_CXX_STANDARD 17)
else ()
set(CMAKE_CXX_STANDARD 11)
endif ()
endif ()

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

find_package(Protobuf REQUIRED)
set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "")
if (APPLE)
find_package(Protobuf REQUIRED CONFIG)
else ()
find_package(Protobuf REQUIRED)
endif ()

set(PROTO_SOURCES PulsarApi.pb.cc)
protobuf_generate_cpp(${PROTO_SOURCES}
Expand Down
2 changes: 2 additions & 0 deletions wireshark/pulsarDissector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ constexpr int kWiresharkMinorVersion = VERSION_MINOR;
#include <glib.h>
#include <wsutil/nstime.h>

#include <map>

#include "PulsarApi.pb.h"

#ifdef VERSION
Expand Down