Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
3b167cb5
Commit
3b167cb5
authored
Dec 08, 2017
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some options & misc changes
parent
26e1625a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
41 deletions
+51
-41
CMakeLists.txt
CMakeLists.txt
+24
-19
build_in_travis_ci.sh
build_in_travis_ci.sh
+10
-0
FindGFLAGS.cmake
cmake/FindGFLAGS.cmake
+15
-15
CMakeLists.txt
src/CMakeLists.txt
+2
-7
No files found.
CMakeLists.txt
View file @
3b167cb5
...
...
@@ -6,26 +6,33 @@ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
endif
()
option
(
WITH_GLOG
"With glog"
OFF
)
option
(
BRPC_DEBUG
"With debug symbol"
ON
)
option
(
BUILD_EXAMPLE
"Whether building examples"
OFF
)
if
(
WITH_GLOG
)
set
(
WITH_GLOG_VAL
"1"
)
else
()
set
(
WITH_GLOG_VAL
"0"
)
endif
()
if
(
BRPC_DEBUG
)
set
(
DEBUG_SYMBOL
"-g"
)
endif
()
configure_file
(
${
CMAKE_SOURCE_DIR
}
/config.h.in
${
CMAKE_SOURCE_DIR
}
/src/butil/config.h @ONLY
)
set
(
CMAKE_MODULE_PATH
${
PROJECT_SOURCE_DIR
}
/cmake
)
find_package
(
G
flags
REQUIRED
)
find_package
(
G
FLAGS
REQUIRED
)
execute_process
(
COMMAND bash -c
"grep
\"
namespace [_A-Za-z0-9]
\\
+ {
\"
${
G
flags
_INCLUDE_PATH
}
/gflags/gflags_declare.h | head -1 | awk '{print $2}'"
COMMAND bash -c
"grep
\"
namespace [_A-Za-z0-9]
\\
+ {
\"
${
G
FLAGS
_INCLUDE_PATH
}
/gflags/gflags_declare.h | head -1 | awk '{print $2}'"
OUTPUT_VARIABLE GFLAGS_NS
)
# STREQUAL not works. Use MATCHES as workaround
if
(
${
GFLAGS_NS
}
MATCHES
".*GFLAGS_NAMESPACE.*"
)
execute_process
(
COMMAND bash -c
"grep
\"
#define GFLAGS_NAMESPACE [_A-Za-z0-9]
\\
+
\"
${
G
flags
_INCLUDE_PATH
}
/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d
\"\\
n
\"
"
COMMAND bash -c
"grep
\"
#define GFLAGS_NAMESPACE [_A-Za-z0-9]
\\
+
\"
${
G
FLAGS
_INCLUDE_PATH
}
/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d
\"\\
n
\"
"
OUTPUT_VARIABLE GFLAGS_NS
)
endif
()
...
...
@@ -36,36 +43,33 @@ include_directories(
${
CMAKE_CURRENT_BINARY_DIR
}
/src
)
set
(
DEBUG_SYMBOLS
"-g"
)
set
(
CMAKE_CPP_FLAGS
"-DBRPC_WITH_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"
)
set
(
CMAKE_CPP_FLAGS
"
${
CMAKE_CPP_FLAGS
}
${
DEBUG_SYMBOL
S
}
"
)
set
(
CMAKE_CPP_FLAGS
"
${
CMAKE_CPP_FLAGS
}
${
DEBUG_SYMBOL
}
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer"
)
#required by butil/crc32.cc to boost performance for 10x
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4
)
if
(
NOT
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4
)
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-msse4 -msse4.2"
)
endif
()
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0
)
if
(
NOT
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0
)
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-aligned-new"
)
endif
()
find_package
(
Threads REQUIRED
)
find_path
(
GFLAGS_HEADER NAMES gflags/gflags.h PATHS $ENV{GFLAGS_HEADER_PATH}
)
find_library
(
GFLAGS_LIB NAMES gflags PATHS $ENV{GFLAGS_LIB_PATH}
)
#find_path(GFLAGS_HEADER NAMES gflags/gflags.h
)
#find_library(GFLAGS_LIB NAMES gflags
)
#find_package(gflags REQUIRED)
#protobuf 3.2
find_path
(
PROTOBUF_HEADER NAMES google/protobuf/stubs/common.h PATHS $ENV{PB_HEADER_PATH}
)
find_library
(
PROTOBUF_LIB NAMES protobuf PATHS $ENV{PB_LIB_PATH}
)
find_path
(
PROTOBUF_HEADER NAMES google/protobuf/stubs/common.h
)
find_library
(
PROTOBUF_LIB NAMES protobuf
)
find_path
(
LEVELDB_HEADER NAMES leveldb/db.h
PATHS $ENV{LEVELDB_HEADER_PATH}
)
find_library
(
LEVELDB_LIB NAMES leveldb
PATHS $ENV{LEVELDB_LIB_PATH}
)
find_path
(
LEVELDB_HEADER NAMES leveldb/db.h
)
find_library
(
LEVELDB_LIB NAMES leveldb
)
if
(
WITH_GLOG
)
find_path
(
GLOG_HEADER NAMES glog/logging.h
)
...
...
@@ -73,11 +77,10 @@ if(WITH_GLOG)
include_directories
(
${
GLOG_HEADER
}
)
endif
()
#protobuf 3.2
find_library
(
PROTOC_LIB NAMES protoc PATHS $ENV{PB_LIB_PATH}
)
find_library
(
PROTOC_LIB NAMES protoc
)
include_directories
(
${
GFLAGS_
HEADER
}
${
GFLAGS_
INCLUDE_PATH
}
${
PROTOBUF_HEADER
}
${
LEVELDB_HEADER
}
${
THREAD_HEADER
}
...
...
@@ -89,4 +92,6 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set
(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${
CMAKE_BINARY_DIR
}
/lib
)
ADD_SUBDIRECTORY
(
src
)
ADD_SUBDIRECTORY
(
example
)
if
(
BUILD_EXAMPLE
)
ADD_SUBDIRECTORY
(
example
)
endif
()
build_in_travis_ci.sh
View file @
3b167cb5
...
...
@@ -23,3 +23,13 @@ elif [ "$PURPOSE" = "unittest" ]; then
else
echo
"Unknown purpose=
\"
$PURPOSE
\"
"
fi
echo
"start building by cmake"
rm
-rf
build
&&
mkdir
build
&&
cd
build
if
!
cmake
-DBRPC_DEBUG
=
OFF
-BUILD_EXAMPLE
=
ON ..
;
then
echo
"Fail to generate Makefile by cmake"
exit
1
fi
#todo: add test
cmake/FindG
flags
.cmake
→
cmake/FindG
FLAGS
.cmake
View file @
3b167cb5
set
(
_gflags_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES
${
CMAKE_FIND_LIBRARY_SUFFIXES
}
)
find_path
(
G
flags
_INCLUDE_PATH gflags/gflags.h
)
find_path
(
G
FLAGS
_INCLUDE_PATH gflags/gflags.h
)
if
(
G
flags
_STATIC
)
if
(
G
FLAGS
_STATIC
)
if
(
WIN32
)
set
(
CMAKE_FIND_LIBRARY_SUFFIXES .lib
${
CMAKE_FIND_LIBRARY_SUFFIXES
}
)
else
(
WIN32
)
set
(
CMAKE_FIND_LIBRARY_SUFFIXES .a
${
CMAKE_FIND_LIBRARY_SUFFIXES
}
)
endif
(
WIN32
)
endif
(
G
flags
_STATIC
)
find_library
(
G
flags
_LIBRARY NAMES gflags libgflags
)
if
(
G
flags_INCLUDE_PATH AND Gflags
_LIBRARY
)
set
(
G
flags
_FOUND TRUE
)
endif
(
G
flags_INCLUDE_PATH AND Gflags
_LIBRARY
)
if
(
G
flags
_FOUND
)
if
(
NOT G
flags
_FIND_QUIETLY
)
message
(
STATUS
"Found gflags:
${
G
flags
_LIBRARY
}
"
)
endif
(
NOT G
flags
_FIND_QUIETLY
)
else
(
G
flags
_FOUND
)
if
(
G
flags
_FIND_REQUIRED
)
endif
(
G
FLAGS
_STATIC
)
find_library
(
G
FLAGS
_LIBRARY NAMES gflags libgflags
)
if
(
G
FLAGS_INCLUDE_PATH AND GFLAGS
_LIBRARY
)
set
(
G
FLAGS
_FOUND TRUE
)
endif
(
G
FLAGS_INCLUDE_PATH AND GFLAGS
_LIBRARY
)
if
(
G
FLAGS
_FOUND
)
if
(
NOT G
FLAGS
_FIND_QUIETLY
)
message
(
STATUS
"Found gflags:
${
G
FLAGS
_LIBRARY
}
"
)
endif
(
NOT G
FLAGS
_FIND_QUIETLY
)
else
(
G
FLAGS
_FOUND
)
if
(
G
FLAGS
_FIND_REQUIRED
)
message
(
FATAL_ERROR
"Could not find gflags library."
)
endif
(
G
flags
_FIND_REQUIRED
)
endif
(
G
flags
_FOUND
)
endif
(
G
FLAGS
_FIND_REQUIRED
)
endif
(
G
FLAGS
_FOUND
)
set
(
CMAKE_FIND_LIBRARY_SUFFIXES
${
_gflags_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES
}
)
src/CMakeLists.txt
View file @
3b167cb5
project
(
lib
)
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
...
...
@@ -7,9 +5,7 @@ file(GLOB PROTOS "*.proto")
list
(
APPEND PROTO_FLAGS -I
${
CMAKE_CURRENT_BINARY_DIR
}
)
foreach
(
PROTO
${
PROTOS
}
)
get_filename_component
(
PROTO_WE
${
PROTO
}
NAME_WE
)
list
(
APPEND PROTO_SRCS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
PROTO_WE
}
.pb.cc"
)
execute_process
(
COMMAND
${
PROTOBUF_PROTOC_EXECUTABLE
}
${
PROTO_FLAGS
}
--cpp_out=
${
CMAKE_CURRENT_BINARY_DIR
}
--proto_path=
${
PROTOBUF_INCLUDE_DIR
}
--proto_path=
${
CMAKE_SOURCE_DIR
}
/src
${
PROTO
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
...
...
@@ -19,9 +15,7 @@ endforeach()
file
(
GLOB brpc_PROTOS
"brpc/*.proto"
)
foreach
(
PROTO
${
brpc_PROTOS
}
)
get_filename_component
(
PROTO_WE
${
PROTO
}
NAME_WE
)
list
(
APPEND PROTO_SRCS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/brpc/
${
PROTO_WE
}
.pb.cc"
)
execute_process
(
COMMAND
${
PROTOBUF_PROTOC_EXECUTABLE
}
${
PROTO_FLAGS
}
--cpp_out=
${
CMAKE_CURRENT_BINARY_DIR
}
--proto_path=
${
PROTOBUF_INCLUDE_DIR
}
--proto_path=
${
CMAKE_SOURCE_DIR
}
/src --proto_path=
${
CMAKE_SOURCE_DIR
}
/src/brpc/
${
PROTO
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
...
...
@@ -197,7 +191,8 @@ add_library(brpc_static STATIC ${SOURCES})
target_link_libraries
(
brpc
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIB
}
#${GFLAGS_LIB}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIB
}
${
LEVELDB_LIB
}
rt
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment