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
906b448c
Commit
906b448c
authored
Mar 28, 2018
by
Jason S Zang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate protos into dependency system so reconfiguration no longer triggers recompiling
parent
9a08ce55
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
52 deletions
+81
-52
CMakeLists.txt
CMakeLists.txt
+25
-33
CompileProto.cmake
cmake/CompileProto.cmake
+20
-0
CMakeLists.txt
src/CMakeLists.txt
+6
-2
CMakeLists.txt
test/CMakeLists.txt
+30
-17
No files found.
CMakeLists.txt
View file @
906b448c
...
...
@@ -282,36 +282,31 @@ set(MCPACK2PB_SOURCES
${
CMAKE_SOURCE_DIR
}
/src/mcpack2pb/serializer.cpp
)
file
(
GLOB PROTOS
"
${
CMAKE_SOURCE_DIR
}
/src/*.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
}
)
endforeach
()
file
(
GLOB BRPC_PROTOS
"src/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
}
)
endforeach
()
file
(
GLOB BRPC_POLICY_PROTOS
"src/brpc/policy/*.proto"
)
foreach
(
PROTO
${
BRPC_POLICY_PROTOS
}
)
get_filename_component
(
PROTO_WE
${
PROTO
}
NAME_WE
)
list
(
APPEND PROTO_SRCS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/brpc/policy/
${
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/policy
${
PROTO
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
endforeach
()
include
(
CompileProto
)
set
(
PROTO_FILES idl_options.proto
brpc/rtmp.proto
brpc/rpc_dump.proto
brpc/get_favicon.proto
brpc/span.proto
brpc/builtin_service.proto
brpc/get_js.proto
brpc/errno.proto
brpc/nshead_meta.proto
brpc/options.proto
brpc/policy/baidu_rpc_meta.proto
brpc/policy/hulu_pbrpc_meta.proto
brpc/policy/public_pbrpc_meta.proto
brpc/policy/sofa_pbrpc_meta.proto
brpc/policy/mongo.proto
brpc/trackme.proto
brpc/streaming_rpc_meta.proto
)
file
(
MAKE_DIRECTORY
${
CMAKE_BINARY_DIR
}
/output/include/brpc
)
set
(
PROTOC_FLAGS
${
PROTOC_FLAGS
}
-I
${
PROTOBUF_INCLUDE_DIR
}
)
compile_proto
(
PROTO_HDRS PROTO_SRCS
${
CMAKE_BINARY_DIR
}
${
CMAKE_BINARY_DIR
}
/output/include
${
CMAKE_SOURCE_DIR
}
/src
"
${
PROTO_FILES
}
"
)
add_library
(
PROTO_LIB OBJECT
${
PROTO_SRCS
}
${
PROTO_HDRS
}
)
set
(
SOURCES
${
BVAR_SOURCES
}
...
...
@@ -319,7 +314,6 @@ set(SOURCES
${
JSON2PB_SOURCES
}
${
MCPACK2PB_SOURCES
}
${
BRPC_SOURCES
}
${
PROTO_SRCS
}
)
add_subdirectory
(
src
)
...
...
@@ -328,8 +322,6 @@ if(BUILD_UNIT_TESTS)
endif
()
add_subdirectory
(
tools
)
file
(
COPY
${
CMAKE_CURRENT_BINARY_DIR
}
/idl_options.pb.h
DESTINATION
${
CMAKE_CURRENT_BINARY_DIR
}
/output/include
)
file
(
COPY
${
CMAKE_CURRENT_BINARY_DIR
}
/brpc/
DESTINATION
${
CMAKE_CURRENT_BINARY_DIR
}
/output/include/brpc/
FILES_MATCHING
...
...
cmake/CompileProto.cmake
0 → 100644
View file @
906b448c
function
(
compile_proto OUT_HDRS OUT_SRCS DESTDIR HDR_OUTPUT_DIR PROTO_DIR PROTO_FILES
)
foreach
(
P
${
PROTO_FILES
}
)
string
(
REPLACE .proto .pb.h HDR
${
P
}
)
set
(
HDR_RELATIVE
${
HDR
}
)
set
(
HDR
${
DESTDIR
}
/
${
HDR
}
)
string
(
REPLACE .proto .pb.cc SRC
${
P
}
)
set
(
SRC
${
DESTDIR
}
/
${
SRC
}
)
list
(
APPEND HDRS
${
HDR
}
)
list
(
APPEND SRCS
${
SRC
}
)
add_custom_command
(
OUTPUT
${
HDR
}
${
SRC
}
COMMAND
${
PROTOBUF_PROTOC_EXECUTABLE
}
${
PROTOC_FLAGS
}
-I
${
PROTO_DIR
}
--cpp_out=
${
DESTDIR
}
${
PROTO_DIR
}
/
${
P
}
COMMAND
${
CMAKE_COMMAND
}
-E copy
${
HDR
}
${
HDR_OUTPUT_DIR
}
/
${
HDR_RELATIVE
}
DEPENDS
${
PROTO_DIR
}
/
${
P
}
)
endforeach
()
set
(
${
OUT_HDRS
}
${
HDRS
}
PARENT_SCOPE
)
set
(
${
OUT_SRCS
}
${
SRCS
}
PARENT_SCOPE
)
endfunction
()
\ No newline at end of file
src/CMakeLists.txt
View file @
906b448c
...
...
@@ -16,8 +16,12 @@ add_library(OBJ_LIB OBJECT ${SOURCES})
set_property
(
TARGET
${
OBJ_LIB
}
PROPERTY POSITION_INDEPENDENT_CODE 1
)
set_property
(
TARGET
${
BUTIL_LIB
}
PROPERTY POSITION_INDEPENDENT_CODE 1
)
add_library
(
brpc-shared SHARED $<TARGET_OBJECTS:BUTIL_LIB> $<TARGET_OBJECTS:OBJ_LIB>
)
add_library
(
brpc-static STATIC $<TARGET_OBJECTS:BUTIL_LIB> $<TARGET_OBJECTS:OBJ_LIB>
)
add_library
(
brpc-shared SHARED $<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:OBJ_LIB>
$<TARGET_OBJECTS:PROTO_LIB>
)
add_library
(
brpc-static STATIC $<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:OBJ_LIB>
$<TARGET_OBJECTS:PROTO_LIB>
)
target_link_libraries
(
brpc-shared
${
DYNAMIC_LIB
}
)
...
...
test/CMakeLists.txt
View file @
906b448c
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
}
)
foreach
(
PROTO
${
PROTOS
}
)
get_filename_component
(
PROTO_WE
${
PROTO
}
NAME_WE
)
list
(
APPEND TEST_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_path=
${
CMAKE_SOURCE_DIR
}
/test
${
PROTO
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
endforeach
()
include
(
CompileProto
)
set
(
TEST_PROTO_FILES addressbook1.proto
addressbook_encode_decode.proto
addressbook_map.proto
addressbook.proto
echo.proto
iobuf.proto
message.proto
repeated.proto
snappy_message.proto
v1.proto
v2.proto
)
file
(
MAKE_DIRECTORY
${
CMAKE_BINARY_DIR
}
/test/hdrs
)
set
(
PROTOC_FLAGS
${
PROTOC_FLAGS
}
-I
${
CMAKE_SOURCE_DIR
}
/src
)
compile_proto
(
PROTO_HDRS PROTO_SRCS
${
CMAKE_BINARY_DIR
}
/test
${
CMAKE_BINARY_DIR
}
/test/hdrs
${
CMAKE_SOURCE_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."
OFF
)
set
(
BRPC_SYSTEM_GTEST_SOURCE_DIR
""
CACHE PATH
"System googletest source directory."
)
...
...
@@ -151,26 +161,28 @@ list(REMOVE_ITEM BVAR_SOURCES ${CMAKE_SOURCE_DIR}/src/bvar/default_variables.cpp
file
(
GLOB TEST_BVAR_SRCS
"bvar_*_unittest.cpp"
)
add_executable
(
test_bvar $<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:PROTO_LIB>
${
BVAR_SOURCES
}
${
TEST_BVAR_SRCS
}
)
target_link_libraries
(
test_bvar gtest
${
GPERFTOOLS_LIBRARIES
}
${
DYNAMIC_LIB
}
)
add_library
(
TEST_PROTO_OBJ OBJECT
${
TEST_PROTO_SRCS
}
)
add_executable
(
test_butil
${
TEST_BUTIL_SOURCES
}
$<TARGET_OBJECTS:TEST_PROTO_
OBJ
>
$<TARGET_OBJECTS:TEST_PROTO_
LIB
>
$<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:OBJ_LIB>
)
$<TARGET_OBJECTS:OBJ_LIB>
$<TARGET_OBJECTS:PROTO_LIB>
)
target_link_libraries
(
test_butil gtest
${
GPERFTOOLS_LIBRARIES
}
${
DYNAMIC_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
}
$<TARGET_OBJECTS:TEST_PROTO_
OBJ
>
$<TARGET_OBJECTS:TEST_PROTO_
LIB
>
$<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:OBJ_LIB>
)
$<TARGET_OBJECTS:OBJ_LIB>
$<TARGET_OBJECTS:PROTO_LIB>
)
target_link_libraries
(
${
BTHREAD_UT_WE
}
gtest_main
${
GPERFTOOLS_LIBRARIES
}
...
...
@@ -181,9 +193,10 @@ 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_
OBJ
>
$<TARGET_OBJECTS:TEST_PROTO_
LIB
>
$<TARGET_OBJECTS:BUTIL_LIB>
$<TARGET_OBJECTS:OBJ_LIB>
)
$<TARGET_OBJECTS:OBJ_LIB>
$<TARGET_OBJECTS:PROTO_LIB>
)
target_link_libraries
(
${
BRPC_UT_WE
}
gtest_main
${
GPERFTOOLS_LIBRARIES
}
...
...
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