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

lizhanhui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git


The following commit(s) were added to refs/heads/master by this push:
     new 47e1467  Verify compile using CMake on Ubuntu (#83)
47e1467 is described below

commit 47e1467101e3708aa18c7ac09c125b4408c2d164
Author: Zhanhui Li <[email protected]>
AuthorDate: Thu Jul 28 18:09:12 2022 +0800

    Verify compile using CMake on Ubuntu (#83)
---
 cpp/CMakeLists.txt          |  1 +
 cpp/README.md               | 51 ++++++++++++++++++++++++++++++++++++++++-----
 cpp/examples/CMakeLists.txt |  2 +-
 3 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 031130c..374466e 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -29,5 +29,6 @@ if (BUILD_EXAMPLES)
     # Assume gflags is install in $HOME/gflags
     list(APPEND CMAKE_PREFIX_PATH $ENV{HOME}/gflags)
     find_package(gflags REQUIRED)
+    find_package(ZLIB REQUIRED)
     add_subdirectory(examples)
 endif ()
\ No newline at end of file
diff --git a/cpp/README.md b/cpp/README.md
index a0a04c4..8b7796b 100644
--- a/cpp/README.md
+++ b/cpp/README.md
@@ -65,11 +65,52 @@ if "com_google_googletest" not in native.existing_rules():
 
 2. Following [gRPC installation 
instructions](https://grpc.io/docs/languages/cpp/quickstart/) to install grpc.
 
-   Note: Remember to `export MY_INSTALL_DIR=$HOME/grpc` as our primary 
CMakeLists.txt hints 
-   ```cmake
-   list(APPEND CMAKE_PREFIX_PATH $ENV{HOME}/grpc)
-   ```
-   If your grpc is installed somewhere else yet non-standard, please adjust 
accordingly.
+   Note: 
+      * Remember to `export MY_INSTALL_DIR=$HOME/grpc` as our primary 
CMakeLists.txt hints 
+
+         ```cmake
+         list(APPEND CMAKE_PREFIX_PATH $ENV{HOME}/grpc)
+         ```
+         If your grpc is installed somewhere else yet non-standard, please 
adjust accordingly.
+
+      * When configure grpc, use your pre-installed system package if 
possible; 
+         ```shell
+         cmake -DCMAKE_INSTALL_PREFIX=$HOME/grpc -DgRPC_SSL_PROVIDER=package 
-DgRPC_ZLIB_PROVIDER=package
+         ```
+         A few more options are involved. Check CMakeLists.txt of grpc
+         ```cmake
+         # Providers for third-party dependencies (gRPC_*_PROVIDER properties):
+         # "module": build the dependency using sources from git submodule 
(under third_party)
+         # "package": use cmake's find_package functionality to locate a 
pre-installed dependency
+
+         set(gRPC_ZLIB_PROVIDER "module" CACHE STRING "Provider of zlib 
library")
+         set_property(CACHE gRPC_ZLIB_PROVIDER PROPERTY STRINGS "module" 
"package")
+
+         set(gRPC_CARES_PROVIDER "module" CACHE STRING "Provider of c-ares 
library")
+         set_property(CACHE gRPC_CARES_PROVIDER PROPERTY STRINGS "module" 
"package")
+
+         set(gRPC_RE2_PROVIDER "module" CACHE STRING "Provider of re2 library")
+         set_property(CACHE gRPC_RE2_PROVIDER PROPERTY STRINGS "module" 
"package")
+
+         set(gRPC_SSL_PROVIDER "module" CACHE STRING "Provider of ssl library")
+         set_property(CACHE gRPC_SSL_PROVIDER PROPERTY STRINGS "module" 
"package")
+
+         set(gRPC_PROTOBUF_PROVIDER "module" CACHE STRING "Provider of 
protobuf library")
+         set_property(CACHE gRPC_PROTOBUF_PROVIDER PROPERTY STRINGS "module" 
"package")
+
+         set(gRPC_PROTOBUF_PACKAGE_TYPE "" CACHE STRING "Algorithm for 
searching protobuf package")
+         set_property(CACHE gRPC_PROTOBUF_PACKAGE_TYPE PROPERTY STRINGS 
"CONFIG" "MODULE")
+
+         if(gRPC_BUILD_TESTS)
+         set(gRPC_BENCHMARK_PROVIDER "module" CACHE STRING "Provider of 
benchmark library")
+         set_property(CACHE gRPC_BENCHMARK_PROVIDER PROPERTY STRINGS "module" 
"package")
+         else()
+         set(gRPC_BENCHMARK_PROVIDER "none")
+         endif()
+
+         set(gRPC_ABSL_PROVIDER "module" CACHE STRING "Provider of absl 
library")
+         set_property(CACHE gRPC_ABSL_PROVIDER PROPERTY STRINGS "module" 
"package")
+         ```
 
 3. Example programs uses [gflags](https://github.com/gflags/gflags) to parse 
command arguments. Please install it to $HOME/gflags
    as CMakeLists.txt has the following find package statements
diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt
index b19c65e..8d6b039 100644
--- a/cpp/examples/CMakeLists.txt
+++ b/cpp/examples/CMakeLists.txt
@@ -1,6 +1,6 @@
 function(add_example name file)
     add_executable(${name} ${file})
-    target_link_libraries(${name} PRIVATE api gflags rocketmq)
+    target_link_libraries(${name} PRIVATE api gflags ZLIB::ZLIB rocketmq)
 endfunction()
 
 add_example(example_producer ExampleProducer.cpp)

Reply via email to