Commit a5e92566 authored by zhujiashun's avatar zhujiashun

modify docs/cn/getting_started.md to support cmake

parent 440945a0
...@@ -36,6 +36,14 @@ To change compiler to clang, add `--cxx=clang++ --cc=clang`. ...@@ -36,6 +36,14 @@ To change compiler to clang, add `--cxx=clang++ --cc=clang`.
To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller. To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller.
### Compile brpc with cmake
```
$ mkdir build && cd build && cmake .. && make
```
To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
Use `cmake -DWITH_DEBUG_SYMBOLS=ON ..` to link debugging symbols.
### Run example ### Run example
``` ```
...@@ -48,6 +56,15 @@ Examples link brpc statically, if you need to link the shared version, `make cle ...@@ -48,6 +56,15 @@ Examples link brpc statically, if you need to link the shared version, `make cle
To run examples with cpu/heap profilers, install `libgoogle-perftools-dev` and re-run `config_brpc.sh` before compiling. To run examples with cpu/heap profilers, install `libgoogle-perftools-dev` and re-run `config_brpc.sh` before compiling.
### Run example with cmake
```
$ cd example/echo_c++
$ mkdir build && cd build && cmake .. && make
$ ./echo_server &
$ ./echo_client
```
Examples link brpc statically, if you need to link the shared version, use `cmake -DEXAMPLE_LINK_SO=ON ..`
### Run tests ### Run tests
Install and compile libgtest-dev (which is not compiled yet): Install and compile libgtest-dev (which is not compiled yet):
...@@ -59,6 +76,15 @@ The directory of gtest source code may be changed, try `/usr/src/googletest/goog ...@@ -59,6 +76,15 @@ The directory of gtest source code may be changed, try `/usr/src/googletest/goog
Rerun `config_brpc.sh`, `make` in test/, and `sh run_tests.sh` Rerun `config_brpc.sh`, `make` in test/, and `sh run_tests.sh`
### Run tests with cmake
Install gtest like just written above.
```
$ mkdir build && cd build && cmake -DBUILD_UNIT_TESTS=ON .. && make
$ cd test && sh run_tests.sh
```
## Fedora/CentOS ## Fedora/CentOS
### Prepare deps ### Prepare deps
...@@ -89,6 +115,14 @@ To change compiler to clang, add `--cxx=clang++ --cc=clang`. ...@@ -89,6 +115,14 @@ To change compiler to clang, add `--cxx=clang++ --cc=clang`.
To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller. To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller.
### Compile brpc with cmake
```
$ mkdir build && cd build && cmake .. && make
```
To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
Use `cmake -DWITH_DEBUG_SYMBOLS=ON ..` to link debugging symbols.
### Run example ### Run example
``` ```
...@@ -101,12 +135,28 @@ Examples link brpc statically, if you need to link the shared version, `make cle ...@@ -101,12 +135,28 @@ Examples link brpc statically, if you need to link the shared version, `make cle
To run examples with cpu/heap profilers, install `gperftools-devel` and re-run `config_brpc.sh` before compiling. To run examples with cpu/heap profilers, install `gperftools-devel` and re-run `config_brpc.sh` before compiling.
### Run example with cmake
```
$ cd example/echo_c++
$ mkdir build && cd build && cmake .. && make
$ ./echo_server &
$ ./echo_client
```
Examples link brpc statically, if you need to link the shared version, use `cmake -DEXAMPLE_LINK_SO=ON ..`
### Run tests ### Run tests
Install gtest-devel. Install gtest-devel.
Rerun `config_brpc.sh`, `make` in test/, and `sh run_tests.sh` Rerun `config_brpc.sh`, `make` in test/, and `sh run_tests.sh`
### Run tests with cmake
```
$ mkdir build && cd build && cmake -DBUILD_UNIT_TESTS=ON .. && make
$ cd test && sh run_tests.sh
```
## Linux with self-built deps ## Linux with self-built deps
### Prepare deps ### Prepare deps
...@@ -144,6 +194,18 @@ $ sh config_brpc.sh --headers=.. --libs=.. ...@@ -144,6 +194,18 @@ $ sh config_brpc.sh --headers=.. --libs=..
$ make $ make
``` ```
### Compile brpc with cmake
git clone brpc. cd into the repo and run
```
$ mkdir build && cd build && cmake -DCMAKE_INCLUDE_PATH="/path/to/dep1/include;/path/to/dep2/include" -DCMAKE_LIBRARY_PATH="/path/to/dep1/lib;/path/to/dep2/lib" .. && make
```
To change compiler to clang, overwrite environment variable CC and CXX to clang and clang++.
Add `-DWITH_DEBUG_SYMBOLS=ON` to link debugging symbols.
# Supported deps # Supported deps
## GCC: 4.8-7.1 ## GCC: 4.8-7.1
...@@ -200,11 +262,11 @@ When you remove tcmalloc, not only remove the linkage with tcmalloc but also the ...@@ -200,11 +262,11 @@ When you remove tcmalloc, not only remove the linkage with tcmalloc but also the
## glog: 3.3+ ## glog: 3.3+
brpc implementes a default [logging utility](../../src/butil/logging.h) which conflicts with glog. To replace this with glog, add *--with-glog* to config_brpc.sh brpc implementes a default [logging utility](../../src/butil/logging.h) which conflicts with glog. To replace this with glog, add *--with-glog* to config_brpc.sh or add `-DWITH_GLOG=ON` to cmake.
## valgrind: 3.8+ ## valgrind: 3.8+
brpc detects valgrind automatically (and registers stacks of bthread). Older valgrind (say 3.2) is not supported. brpc detects valgrind automatically (and registers stacks of bthread). Older valgrind(say 3.2) is not supported.
# Track instances # Track instances
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment