You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by xy...@apache.org on 2023/05/16 02:59:10 UTC

[pulsar-client-cpp] branch main updated: Support specifying the C++ standard for some higher dependencies (#269)

This is an automated email from the ASF dual-hosted git repository.

xyz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 191a6b4  Support specifying the C++ standard for some higher dependencies (#269)
191a6b4 is described below

commit 191a6b4a9484aadce0b00b4fb75b104e0d371d7a
Author: Yunze Xu <xy...@163.com>
AuthorDate: Tue May 16 10:59:03 2023 +0800

    Support specifying the C++ standard for some higher dependencies (#269)
    
    Fixes https://github.com/apache/pulsar-client-cpp/issues/268
    
    ### Motivation
    
    When users build from source with a dependency that requires a higher
    C++ version than 11, it will fail because currently the C++ standard is
    pinned to 11. For example, the latest GTest requires C++14 now. So
    currently there is no way to build the tests except modifying the
    CMakeLists.txt file.
    
    ### Modifications
    
    Make `CMAKE_CXX_STANDARD` configurable and test it for the macOS
    workflow because the `gtest` dependency installed from `brew` requires
    C++14. Add the description into the README for it.
---
 .github/workflows/ci-pr-validation.yaml | 5 +++--
 CMakeLists.txt                          | 4 +++-
 README.md                               | 6 ++++++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/ci-pr-validation.yaml b/.github/workflows/ci-pr-validation.yaml
index a736bb6..259a277 100644
--- a/.github/workflows/ci-pr-validation.yaml
+++ b/.github/workflows/ci-pr-validation.yaml
@@ -267,14 +267,15 @@ jobs:
         uses: actions/checkout@v3
 
       - name: Install dependencies
-        run: brew install openssl protobuf boost zstd snappy
+        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 \
-              -DBUILD_TESTS=OFF \
+              -DCMAKE_CXX_STANDARD=14 \
               -S .
 
       - name: Compile
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a8f56aa..dedea25 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -88,7 +88,9 @@ find_package(Threads REQUIRED)
 MESSAGE(STATUS "Threads library: " ${CMAKE_THREAD_LIBS_INIT})
 
 set(Boost_NO_BOOST_CMAKE ON)
-set(CMAKE_CXX_STANDARD 11)
+if (NOT CMAKE_CXX_STANDARD)
+    set(CMAKE_CXX_STANDARD 11)
+endif ()
 set(CMAKE_C_STANDARD 11)
 
 # Compiler specific configuration:
diff --git a/README.md b/README.md
index 6c0547b..208c4e9 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,12 @@ If you want to build and run the tests, you need to install [GTest](https://gith
 
 If you want to use `ClientConfiguration::setLogConfFilePath`, you need to install the [Log4CXX](https://logging.apache.org/log4cxx) and add CMake option `-DUSE_LOG4CXX=ON`.
 
+The [dependencies.yaml](./dependencies.yaml) file provides the recommended dependency versions, while you can still build from source with other dependency versions. If a dependency requires a higher C++ standard, e.g. C++14, you can specify the standard like:
+
+```bash
+cmake . -DCMAKE_CXX_STANDARD=14
+```
+
 ## Platforms
 
 Pulsar C++ Client Library has been tested on: