forked from apache/brpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhujiashun
committed
Jan 7, 2018
1 parent
c1e1661
commit 4eeeeb1
Showing
25 changed files
with
1,744 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,86 @@ | ||
cmake_minimum_required(VERSION 2.8.10) | ||
project(asynchronous_echo_c++ C CXX) | ||
|
||
# if you want to specify the path of brpc header and lib, | ||
# set the following two variables. | ||
#set(CMAKE_INCLUDE_PATH /path/to/include) | ||
#set(CMAKE_LIBRARY_PATH /path/to/lib) | ||
|
||
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF) | ||
|
||
include(FindThreads) | ||
include(FindProtobuf) | ||
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto) | ||
get_filename_component(HEADER_DIR ${PROTO_HEADER} DIRECTORY) | ||
include_directories(${HEADER_DIR}) | ||
# include PROTO_HEADER | ||
include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
set(CMAKE_CPP_FLAGS "-DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}") | ||
find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h) | ||
if(EXAMPLE_LINK_SO) | ||
find_library(BRPC_LIB NAMES brpc) | ||
else() | ||
find_library(BRPC_LIB NAMES libbrpc_static.a brpc) | ||
endif() | ||
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB)) | ||
message(FATAL_ERROR "Fail to find brpc") | ||
endif() | ||
include_directories(${BRPC_INCLUDE_PATH}) | ||
|
||
find_path(GFLAGS_INCLUDE_PATH gflags/gflags.h) | ||
find_library(GFLAGS_LIBRARY NAMES gflags libgflags) | ||
if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) | ||
message(FATAL_ERROR "Fail to find gflags") | ||
endif() | ||
include_directories(${GFLAGS_INCLUDE_PATH}) | ||
|
||
execute_process( | ||
COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" | ||
OUTPUT_VARIABLE GFLAGS_NS | ||
) | ||
if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") | ||
execute_process( | ||
COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" | ||
OUTPUT_VARIABLE GFLAGS_NS | ||
) | ||
endif() | ||
set(CMAKE_CPP_FLAGS "-DGFLAGS_NS=${GFLAGS_NS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") | ||
|
||
if(CMAKE_VERSION VERSION_LESS "3.1.3") | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | ||
endif() | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | ||
endif() | ||
else() | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
endif() | ||
|
||
find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h) | ||
find_library(LEVELDB_LIB NAMES leveldb) | ||
if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB)) | ||
message(FATAL_ERROR "Fail to find leveldb") | ||
endif() | ||
include_directories(${LEVELDB_INCLUDE_PATH}) | ||
|
||
set(DYNAMIC_LIB | ||
${CMAKE_THREAD_LIBS_INIT} | ||
${GFLAGS_LIBRARY} | ||
${PROTOBUF_LIBRARIES} | ||
${LEVELDB_LIB} | ||
ssl | ||
crypto | ||
dl | ||
) | ||
|
||
add_executable(asynchronous_echo_client client.cpp ${PROTO_SRC}) | ||
add_executable(asynchronous_echo_server server.cpp ${PROTO_SRC}) | ||
|
||
if(EXAMPLE_LINK_SO) | ||
target_link_libraries(asynchronous_echo_client brpc) | ||
target_link_libraries(asynchronous_echo_server brpc) | ||
target_link_libraries(asynchronous_echo_client ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
target_link_libraries(asynchronous_echo_server ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
else() | ||
target_link_libraries(asynchronous_echo_client brpc_static ${DYNAMIC_LIB}) | ||
target_link_libraries(asynchronous_echo_server brpc_static ${DYNAMIC_LIB}) | ||
target_link_libraries(asynchronous_echo_client ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
target_link_libraries(asynchronous_echo_server ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,86 @@ | ||
cmake_minimum_required(VERSION 2.8.10) | ||
project(backup_request_c++ C CXX) | ||
|
||
# if you want to specify the path of brpc header and lib, | ||
# set the following two variables. | ||
#set(CMAKE_INCLUDE_PATH /path/to/include) | ||
#set(CMAKE_LIBRARY_PATH /path/to/lib) | ||
|
||
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF) | ||
|
||
include(FindThreads) | ||
include(FindProtobuf) | ||
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto) | ||
get_filename_component(HEADER_DIR ${PROTO_HEADER} DIRECTORY) | ||
include_directories(${HEADER_DIR}) | ||
# include PROTO_HEADER | ||
include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
set(CMAKE_CPP_FLAGS "-DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}") | ||
find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h) | ||
if(EXAMPLE_LINK_SO) | ||
find_library(BRPC_LIB NAMES brpc) | ||
else() | ||
find_library(BRPC_LIB NAMES libbrpc_static.a brpc) | ||
endif() | ||
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB)) | ||
message(FATAL_ERROR "Fail to find brpc") | ||
endif() | ||
include_directories(${BRPC_INCLUDE_PATH}) | ||
|
||
find_path(GFLAGS_INCLUDE_PATH gflags/gflags.h) | ||
find_library(GFLAGS_LIBRARY NAMES gflags libgflags) | ||
if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) | ||
message(FATAL_ERROR "Fail to find gflags") | ||
endif() | ||
include_directories(${GFLAGS_INCLUDE_PATH}) | ||
|
||
execute_process( | ||
COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" | ||
OUTPUT_VARIABLE GFLAGS_NS | ||
) | ||
if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") | ||
execute_process( | ||
COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" | ||
OUTPUT_VARIABLE GFLAGS_NS | ||
) | ||
endif() | ||
set(CMAKE_CPP_FLAGS "-DGFLAGS_NS=${GFLAGS_NS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") | ||
|
||
if(CMAKE_VERSION VERSION_LESS "3.1.3") | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | ||
endif() | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | ||
endif() | ||
else() | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
endif() | ||
|
||
find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h) | ||
find_library(LEVELDB_LIB NAMES leveldb) | ||
if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB)) | ||
message(FATAL_ERROR "Fail to find leveldb") | ||
endif() | ||
include_directories(${LEVELDB_INCLUDE_PATH}) | ||
|
||
set(DYNAMIC_LIB | ||
${CMAKE_THREAD_LIBS_INIT} | ||
${GFLAGS_LIBRARY} | ||
${PROTOBUF_LIBRARIES} | ||
${LEVELDB_LIB} | ||
ssl | ||
crypto | ||
dl | ||
) | ||
|
||
add_executable(backup_request_client client.cpp ${PROTO_SRC} ${PROTO_HEADER}) | ||
add_executable(backup_request_server server.cpp ${PROTO_SRC} ${PROTO_HEADER}) | ||
|
||
if(EXAMPLE_LINK_SO) | ||
target_link_libraries(backup_request_client brpc) | ||
target_link_libraries(backup_request_server brpc) | ||
target_link_libraries(backup_request_client ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
target_link_libraries(backup_request_server ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
else() | ||
target_link_libraries(backup_request_client brpc_static ${DYNAMIC_LIB}) | ||
target_link_libraries(backup_request_server brpc_static ${DYNAMIC_LIB}) | ||
target_link_libraries(backup_request_client ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
target_link_libraries(backup_request_server ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,86 @@ | ||
cmake_minimum_required(VERSION 2.8.10) | ||
project(cancel_c++ C CXX) | ||
|
||
# if you want to specify the path of brpc header and lib, | ||
# set the following two variables. | ||
#set(CMAKE_INCLUDE_PATH /path/to/include) | ||
#set(CMAKE_LIBRARY_PATH /path/to/lib) | ||
|
||
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF) | ||
|
||
include(FindThreads) | ||
include(FindProtobuf) | ||
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto) | ||
get_filename_component(HEADER_DIR ${PROTO_HEADER} DIRECTORY) | ||
include_directories(${HEADER_DIR}) | ||
# include PROTO_HEADER | ||
include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
set(CMAKE_CPP_FLAGS "-DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}") | ||
find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h) | ||
if(EXAMPLE_LINK_SO) | ||
find_library(BRPC_LIB NAMES brpc) | ||
else() | ||
find_library(BRPC_LIB NAMES libbrpc_static.a brpc) | ||
endif() | ||
if((NOT BRPC_INCLUDE_PATH) OR (NOT BRPC_LIB)) | ||
message(FATAL_ERROR "Fail to find brpc") | ||
endif() | ||
include_directories(${BRPC_INCLUDE_PATH}) | ||
|
||
find_path(GFLAGS_INCLUDE_PATH gflags/gflags.h) | ||
find_library(GFLAGS_LIBRARY NAMES gflags libgflags) | ||
if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY)) | ||
message(FATAL_ERROR "Fail to find gflags") | ||
endif() | ||
include_directories(${GFLAGS_INCLUDE_PATH}) | ||
|
||
execute_process( | ||
COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'" | ||
OUTPUT_VARIABLE GFLAGS_NS | ||
) | ||
if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE") | ||
execute_process( | ||
COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'" | ||
OUTPUT_VARIABLE GFLAGS_NS | ||
) | ||
endif() | ||
set(CMAKE_CPP_FLAGS "-DGFLAGS_NS=${GFLAGS_NS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer") | ||
|
||
if(CMAKE_VERSION VERSION_LESS "3.1.3") | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | ||
endif() | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | ||
endif() | ||
else() | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
endif() | ||
|
||
find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h) | ||
find_library(LEVELDB_LIB NAMES leveldb) | ||
if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB)) | ||
message(FATAL_ERROR "Fail to find leveldb") | ||
endif() | ||
include_directories(${LEVELDB_INCLUDE_PATH}) | ||
|
||
set(DYNAMIC_LIB | ||
${CMAKE_THREAD_LIBS_INIT} | ||
${GFLAGS_LIBRARY} | ||
${PROTOBUF_LIBRARIES} | ||
${LEVELDB_LIB} | ||
ssl | ||
crypto | ||
dl | ||
) | ||
|
||
add_executable(cancel_client client.cpp ${PROTO_SRC} ${PROTO_HEADER}) | ||
add_executable(cancel_server server.cpp ${PROTO_SRC} ${PROTO_HEADER}) | ||
|
||
if(EXAMPLE_LINK_SO) | ||
target_link_libraries(cancel_client brpc) | ||
target_link_libraries(cancel_server brpc) | ||
target_link_libraries(cancel_client ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
target_link_libraries(cancel_server ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
else() | ||
target_link_libraries(cancel_client brpc_static ${DYNAMIC_LIB}) | ||
target_link_libraries(cancel_server brpc_static ${DYNAMIC_LIB}) | ||
target_link_libraries(cancel_client ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
target_link_libraries(cancel_server ${BRPC_LIB} ${DYNAMIC_LIB}) | ||
endif() |
Oops, something went wrong.