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
d070457c
Commit
d070457c
authored
Jun 03, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
separate_cmake_debug_and_release_obj: done
parent
14303060
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
33 deletions
+48
-33
CMakeLists.txt
CMakeLists.txt
+12
-11
CMakeLists.txt
test/CMakeLists.txt
+36
-22
No files found.
CMakeLists.txt
View file @
d070457c
cmake_minimum_required
(
VERSION 2.8.10
)
project
(
brpc C CXX
)
option
(
WITH_GLOG
"With glog"
OFF
)
option
(
DEBUG
"Print debug logs"
OFF
)
option
(
WITH_DEBUG_SYMBOLS
"With debug symbols"
ON
)
option
(
WITH_THRIFT
"With thrift framed protocol supported"
OFF
)
option
(
BUILD_UNIT_TESTS
"Whether to build unit tests"
OFF
)
option
(
DOWNLOAD_GTEST
"Download and build a fresh copy of \
googletest. Requires Internet access."
ON
)
# Enable MACOSX_RPATH. Run "cmake --help-policy CMP0042" for policy details.
if
(
POLICY CMP0042
)
cmake_policy
(
SET CMP0042 NEW
)
...
...
@@ -26,12 +34,6 @@ 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
(
DEBUG
"Print debug logs"
OFF
)
option
(
WITH_DEBUG_SYMBOLS
"With debug symbols"
ON
)
option
(
WITH_THRIFT
"With thrift framed protocol supported"
OFF
)
option
(
BUILD_UNIT_TESTS
"Whether to build unit tests"
OFF
)
set
(
WITH_GLOG_VAL
"0"
)
if
(
WITH_GLOG
)
set
(
WITH_GLOG_VAL
"1"
)
...
...
@@ -166,8 +168,7 @@ set(DYNAMIC_LIB
${
OPENSSL_LIBRARIES
}
${
OPENSSL_CRYPTO_LIBRARY
}
dl
z
)
z
)
set
(
BRPC_PRIVATE_LIBS
"-lgflags -lprotobuf -lleveldb -lprotoc -lssl -lcrypto -ldl -lz"
)
if
(
WITH_GLOG
)
...
...
@@ -197,7 +198,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/lib)
# for *.a
set
(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${
PROJECT_BINARY_DIR
}
/output/lib
)
# list all source files
# the reason why not using file(GLOB_RECURSE...) is that we want to
# include different files on different platforms.
set
(
BUTIL_SOURCES
${
PROJECT_SOURCE_DIR
}
/src/butil/third_party/dmg_fp/g_fmt.cc
${
PROJECT_SOURCE_DIR
}
/src/butil/third_party/dmg_fp/dtoa_wrapper.cc
...
...
@@ -351,8 +353,7 @@ set(MCPACK2PB_SOURCES
${
PROJECT_SOURCE_DIR
}
/src/mcpack2pb/field_type.cpp
${
PROJECT_SOURCE_DIR
}
/src/mcpack2pb/mcpack2pb.cpp
${
PROJECT_SOURCE_DIR
}
/src/mcpack2pb/parser.cpp
${
PROJECT_SOURCE_DIR
}
/src/mcpack2pb/serializer.cpp
)
${
PROJECT_SOURCE_DIR
}
/src/mcpack2pb/serializer.cpp
)
include
(
CompileProto
)
set
(
PROTO_FILES idl_options.proto
...
...
test/CMakeLists.txt
View file @
d070457c
...
...
@@ -24,10 +24,9 @@ compile_proto(PROTO_HDRS PROTO_SRCS ${CMAKE_BINARY_DIR}/test
"
${
TEST_PROTO_FILES
}
"
)
add_library
(
TEST_PROTO_LIB OBJECT
${
PROTO_SRCS
}
${
PROTO_HDRS
}
)
option
(
BRPC_DOWNLOAD_GTEST
"Download and build a fresh copy of googletest. Requires Internet access."
ON
)
set
(
BRPC_SYSTEM_GTEST_SOURCE_DIR
""
CACHE PATH
"System googletest source directory."
)
if
(
BRPC_
DOWNLOAD_GTEST
)
if
(
DOWNLOAD_GTEST
)
include
(
SetupGtest
)
elseif
(
BRPC_SYSTEM_GTEST_SOURCE_DIR
)
add_subdirectory
(
"
${
BRPC_SYSTEM_GTEST_SOURCE_DIR
}
"
"
${
PROJECT_BINARY_DIR
}
/system-googletest-build"
)
...
...
@@ -172,52 +171,67 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
"-Wl,-U,_bthread_key_create"
)
endif
()
# create executable
add_library
(
BUTIL_DEBUG_LIB OBJECT
${
BUTIL_SOURCES
}
)
add_library
(
SOURCES_DEBUG_LIB OBJECT
${
SOURCES
}
)
# shared library needs POSITION_INDEPENDENT_CODE
set_property
(
TARGET
${
BUTIL_DEBUG_LIB
}
PROPERTY POSITION_INDEPENDENT_CODE 1
)
set_property
(
TARGET
${
SOURCES_DEBUG_LIB
}
PROPERTY POSITION_INDEPENDENT_CODE 1
)
add_library
(
brpc-shared-debug SHARED $<TARGET_OBJECTS:BUTIL_DEBUG_LIB>
$<TARGET_OBJECTS:SOURCES_DEBUG_LIB>
$<TARGET_OBJECTS:PROTO_LIB>
)
# change the debug lib output dir to be different from the release output
set_target_properties
(
brpc-shared-debug PROPERTIES
LIBRARY_OUTPUT_DIRECTORY
${
PROJECT_BINARY_DIR
}
/test
)
target_link_libraries
(
brpc-shared-debug
${
DYNAMIC_LIB
}
)
if
(
BRPC_WITH_GLOG
)
target_link_libraries
(
brpc-shared-debug
${
GLOG_LIB
}
)
endif
()
# test_butil
add_executable
(
test_butil
${
TEST_BUTIL_SOURCES
}
${
CMAKE_CURRENT_BINARY_DIR
}
/iobuf.pb.cc
)
target_link_libraries
(
test_butil brpc-shared
target_link_libraries
(
test_butil brpc-shared
-debug
gtest
${
GPERFTOOLS_LIBRARIES
}
${
DYNAMIC_LIB
}
)
${
GPERFTOOLS_LIBRARIES
}
)
add_test
(
NAME test_butil COMMAND test_butil
)
# test_bvar
# -DBVAR_NOT_LINK_DEFAULT_VARIABLES not work for gcc >= 5.0, just remove the file to prevent linking into unit tests
list
(
REMOVE_ITEM BVAR_SOURCES
${
PROJECT_SOURCE_DIR
}
/src/bvar/default_variables.cpp
)
add_library
(
BVAR_
OBJ
OBJECT
${
BVAR_SOURCES
}
)
add_library
(
BVAR_
DEBUG_LIB
OBJECT
${
BVAR_SOURCES
}
)
file
(
GLOB TEST_BVAR_SRCS
"bvar_*_unittest.cpp"
)
add_executable
(
test_bvar
${
TEST_BVAR_SRCS
}
$<TARGET_OBJECTS:BVAR_OBJ> $<TARGET_OBJECTS:BUTIL_LIB>
)
add_executable
(
test_bvar
${
TEST_BVAR_SRCS
}
$<TARGET_OBJECTS:BVAR_DEBUG_LIB>
$<TARGET_OBJECTS:BUTIL_DEBUG_LIB>
)
target_link_libraries
(
test_bvar gtest
${
GPERFTOOLS_LIBRARIES
}
${
DYNAMIC_LIB
}
)
add_test
(
NAME test_bvar COMMAND test_bvar
)
add_library
(
BTHREAD_OBJ OBJECT
${
BTHREAD_SOURCES
}
)
add_library
(
PROTO_OBJ OBJECT
${
PROTO_SRCS
}
)
# bthread tests
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
}
$<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:BVAR_OBJ>
$<TARGET_OBJECTS:BTHREAD_OBJ>
$<TARGET_OBJECTS:PROTO_LIB>
$<TARGET_OBJECTS:TEST_PROTO_LIB>
)
$<TARGET_OBJECTS:TEST_PROTO_LIB>
)
target_link_libraries
(
${
BTHREAD_UT_WE
}
gtest_main
${
GPERFTOOLS_LIBRARIES
}
${
DYNAMIC_LIB
}
)
brpc-shared-debug
${
GPERFTOOLS_LIBRARIES
}
)
add_test
(
NAME
${
BTHREAD_UT_WE
}
COMMAND
${
BTHREAD_UT_WE
}
)
endforeach
()
# brpc tests
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
}
$<TARGET_OBJECTS:TEST_PROTO_LIB>
)
target_link_libraries
(
${
BRPC_UT_WE
}
brpc-shared
target_link_libraries
(
${
BRPC_UT_WE
}
brpc-shared
-debug
gtest_main
${
GPERFTOOLS_LIBRARIES
}
${
GTEST_LIB
}
${
DYNAMIC_LIB
}
)
${
GPERFTOOLS_LIBRARIES
}
)
add_test
(
NAME
${
BRPC_UT_WE
}
COMMAND
${
BRPC_UT_WE
}
)
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