Commit 51a58ccc authored by wangxuefeng's avatar wangxuefeng

unify Marco both with config_brpc.sh and cmake

parent c53d23ae
...@@ -22,14 +22,14 @@ else() ...@@ -22,14 +22,14 @@ else()
message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.") message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.")
endif() endif()
option(BRPC_WITH_GLOG "With glog" OFF) option(WITH_GLOG "With glog" OFF)
option(DEBUG "Print debug logs" OFF) option(DEBUG "Print debug logs" OFF)
option(WITH_DEBUG_SYMBOLS "With debug symbols" ON) option(WITH_DEBUG_SYMBOLS "With debug symbols" ON)
option(BRPC_WITH_THRIFT "With thrift framed protocol supported" OFF) option(WITH_THRIFT "With thrift framed protocol supported" OFF)
option(BUILD_UNIT_TESTS "Whether to build unit tests" OFF) option(BUILD_UNIT_TESTS "Whether to build unit tests" OFF)
set(WITH_GLOG_VAL "0") set(WITH_GLOG_VAL "0")
if(BRPC_WITH_GLOG) if(WITH_GLOG)
set(WITH_GLOG_VAL "1") set(WITH_GLOG_VAL "1")
endif() endif()
...@@ -37,7 +37,7 @@ if(WITH_DEBUG_SYMBOLS) ...@@ -37,7 +37,7 @@ if(WITH_DEBUG_SYMBOLS)
set(DEBUG_SYMBOL "-g") set(DEBUG_SYMBOL "-g")
endif() endif()
if(BRPC_WITH_THRIFT) if(WITH_THRIFT)
set(THRIFT_CPP_FLAG "-DENABLE_THRIFT_FRAMED_PROTOCOL") set(THRIFT_CPP_FLAG "-DENABLE_THRIFT_FRAMED_PROTOCOL")
set(THRIFT_LIB "thriftnb") set(THRIFT_LIB "thriftnb")
endif() endif()
...@@ -79,7 +79,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") ...@@ -79,7 +79,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif() endif()
endif() endif()
set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}") set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DWITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}")
set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\\\"${BRPC_REVISION}\\\" -D__STRICT_ANSI__") set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\\\"${BRPC_REVISION}\\\" -D__STRICT_ANSI__")
set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEBUG_SYMBOL} ${THRIFT_CPP_FLAG}") set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEBUG_SYMBOL} ${THRIFT_CPP_FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer")
...@@ -120,7 +120,7 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB)) ...@@ -120,7 +120,7 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
message(FATAL_ERROR "Fail to find leveldb") message(FATAL_ERROR "Fail to find leveldb")
endif() endif()
if(BRPC_WITH_GLOG) if(WITH_GLOG)
find_path(GLOG_INCLUDE_PATH NAMES glog/logging.h) find_path(GLOG_INCLUDE_PATH NAMES glog/logging.h)
find_library(GLOG_LIB NAMES glog) find_library(GLOG_LIB NAMES glog)
if((NOT GLOG_INCLUDE_PATH) OR (NOT GLOG_LIB)) if((NOT GLOG_INCLUDE_PATH) OR (NOT GLOG_LIB))
...@@ -163,7 +163,7 @@ set(DYNAMIC_LIB ...@@ -163,7 +163,7 @@ set(DYNAMIC_LIB
) )
set(BRPC_PRIVATE_LIBS "-lgflags -lprotobuf -lleveldb -lprotoc -lssl -lcrypto -ldl -lz") set(BRPC_PRIVATE_LIBS "-lgflags -lprotobuf -lleveldb -lprotoc -lssl -lcrypto -ldl -lz")
if(BRPC_WITH_GLOG) if(WITH_GLOG)
set(DYNAMIC_LIB ${DYNAMIC_LIB} ${GLOG_LIB}) set(DYNAMIC_LIB ${DYNAMIC_LIB} ${GLOG_LIB})
set(BRPC_PRIVATE_LIBS "${BRPC_PRIVATE_LIBS} -lglog") set(BRPC_PRIVATE_LIBS "${BRPC_PRIVATE_LIBS} -lglog")
endif() endif()
...@@ -329,7 +329,7 @@ file(GLOB_RECURSE JSON2PB_SOURCES "${CMAKE_SOURCE_DIR}/src/json2pb/*.cpp") ...@@ -329,7 +329,7 @@ file(GLOB_RECURSE JSON2PB_SOURCES "${CMAKE_SOURCE_DIR}/src/json2pb/*.cpp")
file(GLOB_RECURSE BRPC_SOURCES "${CMAKE_SOURCE_DIR}/src/brpc/*.cpp") file(GLOB_RECURSE BRPC_SOURCES "${CMAKE_SOURCE_DIR}/src/brpc/*.cpp")
file(GLOB_RECURSE THRIFT_SOURCES "thrift*.cpp") file(GLOB_RECURSE THRIFT_SOURCES "thrift*.cpp")
if(BRPC_WITH_THRIFT) if(WITH_THRIFT)
message("brpc compile with thrift proctol") message("brpc compile with thrift proctol")
else() else()
# Remove thrift sources # Remove thrift sources
......
...@@ -34,8 +34,8 @@ eval set -- "$TEMP" ...@@ -34,8 +34,8 @@ eval set -- "$TEMP"
# Convert to abspath always so that generated mk is include-able from everywhere # Convert to abspath always so that generated mk is include-able from everywhere
while true; do while true; do
case "$1" in case "$1" in
--headers ) HDRS_IN="$(realpath $2)"; shift 2 ;; --headers ) HDRS_IN="$(readlink -e $2)"; shift 2 ;;
--libs ) LIBS_IN="$(realpath $2)"; shift 2 ;; --libs ) LIBS_IN="$(readlink -e $2)"; shift 2 ;;
--cc ) CC=$2; shift 2 ;; --cc ) CC=$2; shift 2 ;;
--cxx ) CXX=$2; shift 2 ;; --cxx ) CXX=$2; shift 2 ;;
--with-glog ) WITH_GLOG=1; shift 1 ;; --with-glog ) WITH_GLOG=1; shift 1 ;;
......
...@@ -29,7 +29,7 @@ sudo make install ...@@ -29,7 +29,7 @@ sudo make install
```bash ```bash
sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --with-thrift sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --with-thrift
#或者使用cmake #或者使用cmake
mkdir build && cd build && cmake ../ -DBRPC_WITH_THRIFT=1 mkdir build && cd build && cmake ../ -DWITH_THRIFT=1
``` ```
# Client端访问thrift server # Client端访问thrift server
......
...@@ -29,7 +29,7 @@ Config brpc with thrift support, then make. The compiled libbrpc.a includes exte ...@@ -29,7 +29,7 @@ Config brpc with thrift support, then make. The compiled libbrpc.a includes exte
```bash ```bash
sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --with-thrift sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --with-thrift
#or use cmake #or use cmake
mkdir build && cd build && cmake ../ -DBRPC_WITH_THRIFT=1 mkdir build && cd build && cmake ../ -DWITH_THRIFT=1
``` ```
# Client accesses thrift server # Client accesses thrift server
......
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