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
4ccaa33d
Commit
4ccaa33d
authored
Dec 28, 2017
by
zhujiashun
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cmake_support' of github.com:brpc/brpc into cmake_support
parents
e18a8c97
e11f2f51
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
104 additions
and
109 deletions
+104
-109
.travis.yml
.travis.yml
+1
-9
CMakeLists.txt
CMakeLists.txt
+25
-28
FindGperftools.cmake
cmake/FindGperftools.cmake
+51
-0
CMakeLists.txt
example/asynchronous_echo_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/backup_request_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/cancel_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/cascade_echo_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/dynamic_partition_echo_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/echo_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/echo_c++_hulu_pbrpc/CMakeLists.txt
+0
-3
CMakeLists.txt
example/echo_c++_sofa_pbrpc/CMakeLists.txt
+0
-3
CMakeLists.txt
example/echo_c++_ubrpc_compack/CMakeLists.txt
+0
-3
CMakeLists.txt
example/http_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/multi_threaded_echo_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/multi_threaded_echo_fns_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/multi_threaded_mcpack_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/nshead_pb_extension_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/parallel_echo_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/partition_echo_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/selective_echo_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
example/session_data_and_thread_local/CMakeLists.txt
+0
-3
CMakeLists.txt
example/streaming_echo_c++/CMakeLists.txt
+0
-3
CMakeLists.txt
src/CMakeLists.txt
+2
-9
CMakeLists.txt
test/CMakeLists.txt
+25
-6
No files found.
.travis.yml
View file @
4ccaa33d
...
...
@@ -11,16 +11,8 @@ env:
-
PURPOSE=unittest
install
:
-
sudo apt-get install -qq realpath libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev libgoogle-perftools-dev
libpthread-stubs0-dev libboost-all-dev
-
sudo apt-get install -qq realpath libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev libgoogle-perftools-dev
-
sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo env "PATH=$PATH" cmake . && sudo make && sudo mv libgtest* /usr/lib/ && cd -
script
:
-
sh build_in_travis_ci.sh
addons
:
apt
:
sources
:
-
george-edison55-precise-backports
packages
:
-
cmake-data
-
cmake
CMakeLists.txt
View file @
4ccaa33d
cmake_minimum_required
(
VERSION
3.1
)
cmake_minimum_required
(
VERSION
2.8.10
)
project
(
brpc C CXX
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8
)
#message(FATAL_ERROR "GCC is too old, please install a newer version supporting C++11")
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)
# require at least gcc 4.8
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8
)
message
(
FATAL_ERROR
"GCC is too old, please install a newer version supporting C++11"
)
endif
()
elseif
(
CMAKE_CXX_COMPILER_ID STREQUAL
"Clang"
)
# require at least clang 3.3
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3
)
message
(
FATAL_ERROR
"Clang is too old, please install a newer version supporting C++11"
)
endif
()
else
()
message
(
WARNING
"You are using an unsupported compiler! Compilation has only been tested with Clang and GCC."
)
endif
()
option
(
WITH_GLOG
"With glog"
OFF
)
option
(
BRPC_DEBUG
"With debug symbol"
ON
)
option
(
BUILD_EXAMPLE
"Whether building examples"
O
FF
)
option
(
BUILD_EXAMPLE
"Whether building examples"
O
N
)
option
(
BUILD_UNIT_TESTS
"Whether building unit tests"
OFF
)
if
(
WITH_GLOG
)
...
...
@@ -30,8 +40,7 @@ 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
)
# STREQUAL not works. Use MATCHES as workaround
if
(
${
GFLAGS_NS
}
MATCHES
".*GFLAGS_NAMESPACE.*"
)
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
...
...
@@ -49,31 +58,21 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
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
}
"
)
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_C_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer"
)
SET
(
CMAKE_EXE_LINKER_FLAGS
"-pthread"
)
#required by butil/crc32.cc to boost performance for 10x
if
(
NOT
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4
))
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-msse4 -msse4.2"
)
endif
()
if
(
NOT
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0
))
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-aligned-new"
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)
#required by butil/crc32.cc to boost performance for 10x
if
(
NOT
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4
))
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-msse4 -msse4.2"
)
endif
()
if
(
NOT
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0
))
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-aligned-new"
)
endif
()
endif
()
#find_package(Threads REQUIRED)
#find_path(GFLAGS_HEADER NAMES gflags/gflags.h)
#find_library(GFLAGS_LIB NAMES gflags)
#find_package(gflags REQUIRED)
#find_path(THREADS_HEADER NAMES pthread.h)
#find_library(THREADS_LIB NAMES pthread)
find_path
(
PROTOBUF_HEADER NAMES google/protobuf/stubs/common.h
)
find_library
(
PROTOBUF_LIB NAMES protobuf
)
include
(
FindProtobuf
)
find_path
(
LEVELDB_HEADER NAMES leveldb/db.h
)
find_library
(
LEVELDB_LIB NAMES leveldb
)
...
...
@@ -88,10 +87,8 @@ find_library(PROTOC_LIB NAMES protoc)
include_directories
(
${
GFLAGS_INCLUDE_PATH
}
${
PROTOBUF_
HEADER
}
${
PROTOBUF_
INCLUDE_DIRS
}
${
LEVELDB_HEADER
}
${
THREAD_HEADER
}
#${THREADS_HEADER}
)
# for *.so
...
...
cmake/FindGperftools.cmake
0 → 100644
View file @
4ccaa33d
# Tries to find Gperftools.
#
# Usage of this module as follows:
#
# find_package(Gperftools)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# Gperftools_ROOT_DIR Set this variable to the root installation of
# Gperftools if the module has problems finding
# the proper installation path.
#
# Variables defined by this module:
#
# GPERFTOOLS_FOUND System has Gperftools libs/headers
# GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler)
# GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers
find_library
(
GPERFTOOLS_TCMALLOC
NAMES tcmalloc
HINTS
${
Gperftools_ROOT_DIR
}
/lib
)
find_library
(
GPERFTOOLS_PROFILER
NAMES profiler
HINTS
${
Gperftools_ROOT_DIR
}
/lib
)
find_library
(
GPERFTOOLS_TCMALLOC_AND_PROFILER
NAMES tcmalloc_and_profiler
HINTS
${
Gperftools_ROOT_DIR
}
/lib
)
find_path
(
GPERFTOOLS_INCLUDE_DIR
NAMES gperftools/heap-profiler.h
HINTS
${
Gperftools_ROOT_DIR
}
/include
)
set
(
GPERFTOOLS_LIBRARIES
${
GPERFTOOLS_TCMALLOC_AND_PROFILER
}
)
include
(
FindPackageHandleStandardArgs
)
find_package_handle_standard_args
(
Gperftools
DEFAULT_MSG
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR
)
mark_as_advanced
(
Gperftools_ROOT_DIR
GPERFTOOLS_TCMALLOC
GPERFTOOLS_PROFILER
GPERFTOOLS_TCMALLOC_AND_PROFILER
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR
)
example/asynchronous_echo_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/backup_request_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/cancel_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/cascade_echo_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/dynamic_partition_echo_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/echo_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/echo_c++_hulu_pbrpc/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/echo_c++_sofa_pbrpc/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/echo_c++_ubrpc_compack/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
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
}
/example/echo_c++_ubrpc_compack/
${
CMAKE_SOURCE_DIR
}
/example/echo_c++_ubrpc_compack/echo.proto
...
...
example/http_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER http.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/multi_threaded_echo_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/multi_threaded_echo_fns_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/multi_threaded_mcpack_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
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
}
/example/multi_threaded_mcpack_c++
${
CMAKE_SOURCE_DIR
}
/example/multi_threaded_mcpack_c++/echo.proto
...
...
example/nshead_pb_extension_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/parallel_echo_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/partition_echo_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/selective_echo_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/session_data_and_thread_local/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
example/streaming_echo_c++/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
...
...
src/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
file
(
GLOB PROTOS
"*.proto"
)
list
(
APPEND PROTO_FLAGS -I
${
CMAKE_CURRENT_BINARY_DIR
}
)
foreach
(
PROTO
${
PROTOS
}
)
...
...
@@ -191,18 +188,15 @@ add_library(brpc SHARED ${SOURCES})
add_library
(
brpc_static STATIC
${
SOURCES
}
)
target_link_libraries
(
brpc
#${CMAKE_THREAD_LIBS_INIT}
#${THREADS_LIB}
#${GFLAGS_LIB}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIB
}
${
PROTOBUF_LIB
RARIES
}
${
LEVELDB_LIB
}
${
PROTOC_LIB
}
rt
ssl
crypto
dl
z
${
PROTOC_LIB
}
)
if
(
WITH_GLOG
)
...
...
@@ -215,7 +209,6 @@ set(protoc_gen_mcpack_SOURCES
add_executable
(
protoc-gen-mcpack
${
protoc_gen_mcpack_SOURCES
}
)
target_link_libraries
(
protoc-gen-mcpack brpc
)
get_property
(
LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS
)
if
(
"
${
LIB64
}
"
STREQUAL
"TRUE"
)
set
(
LIBSUFFIX 64
)
...
...
test/CMakeLists.txt
View file @
4ccaa33d
include
(
FindProtobuf
)
find_package
(
Protobuf REQUIRED
)
include_directories
(
${
PROTOBUF_INCLUDE_DIR
}
)
find_package
(
Gperftools
)
include_directories
(
${
GPERFTOOLS_INCLUDE_DIR
}
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
file
(
GLOB PROTOS
"*.proto"
)
list
(
APPEND PROTO_FLAGS -I
${
CMAKE_CURRENT_BINARY_DIR
}
)
...
...
@@ -15,12 +14,14 @@ endforeach()
find_path
(
GTEST_HEADER NAMES gtest/gtest.h
)
find_library
(
GTEST_LIB NAMES gtest
)
find_library
(
GTEST_MAIN_LIB NAMES gtest_main
)
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 -DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES -
-
include
${
CMAKE_SOURCE_DIR
}
/test/sstream_workaround.h"
)
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_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 -DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES -include
${
CMAKE_SOURCE_DIR
}
/test/sstream_workaround.h"
)
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
(
TEST_BUTIL_SOURCES
#${CMAKE_SOURCE_DIR}/test/popen_unittest.cpp
${
CMAKE_SOURCE_DIR
}
/test/at_exit_unittest.cc
${
CMAKE_SOURCE_DIR
}
/test/atomicops_unittest.cc
${
CMAKE_SOURCE_DIR
}
/test/base64_unittest.cc
...
...
@@ -116,10 +117,28 @@ SET(TEST_BUTIL_SOURCES
${
CMAKE_SOURCE_DIR
}
/test/test_switches.cc
${
CMAKE_SOURCE_DIR
}
/test/scoped_locale.cc
${
CMAKE_SOURCE_DIR
}
/test/test_file_util_linux.cc
${
CMAKE_SOURCE_DIR
}
/test/popen_unittest.cpp
${
CMAKE_SOURCE_DIR
}
/test/butil_unittest_main.cpp
${
CMAKE_SOURCE_DIR
}
/test/butil_unittest_main.cpp
)
file
(
GLOB TEST_BVAR_SRCS
"bvar_*_unittest.cpp"
)
add_executable
(
test_bvar
${
TEST_BVAR_SRCS
}
${
PROTO_SRCS
}
)
target_link_libraries
(
test_bvar brpc
${
GTEST_LIB
}
${
GPERFTOOLS_LIBRARIES
}
)
add_executable
(
test_butil
${
TEST_BUTIL_SOURCES
}
${
PROTO_SRCS
}
)
target_link_libraries
(
test_butil brpc
${
GTEST_LIB
}
)
file
(
GLOB BTHREAD_UNITTESTS
"bthread*unittest.cpp"
)
foreach
(
BTHREAD_UT
${
BTHREAD_UNITTESTS
}
)
get_filename_component
(
BTHREAD_UT_WE
${
BTHREAD_UT
}
NAME_WE
)
add_executable
(
${
BTHREAD_UT_WE
}
${
BTHREAD_UT
}
${
PROTO_SRCS
}
)
target_link_libraries
(
${
BTHREAD_UT_WE
}
brpc
${
GTEST_MAIN_LIB
}
${
GPERFTOOLS_LIBRARIES
}
${
GTEST_LIB
}
)
endforeach
()
file
(
GLOB BRPC_UNITTESTS
"brpc_*_unittest.cpp"
)
foreach
(
BRPC_UT
${
BRPC_UNITTESTS
}
)
get_filename_component
(
BRPC_UT_WE
${
BRPC_UT
}
NAME_WE
)
add_executable
(
${
BRPC_UT_WE
}
${
BRPC_UT
}
${
PROTO_SRCS
}
)
target_link_libraries
(
${
BRPC_UT_WE
}
brpc
${
GTEST_MAIN_LIB
}
${
GPERFTOOLS_LIBRARIES
}
${
GTEST_LIB
}
)
endforeach
()
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