-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
98 lines (81 loc) · 2.83 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
cmake_minimum_required(VERSION 3.16)
project(tinyRPC)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE "Debug")
find_package(Protobuf REQUIRED)
if (${PROTOBUF_FOUND})
message("protobuf found")
else ()
message(FATAL_ERROR "Cannot find Protobuf")
endif ()
set(JSON_BuildTests OFF CACHE INTERNAL "")
set(JSON_Install OFF CACHE INTERNAL "")
set(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/third_party)
add_subdirectory(${THIRD_PARTY_DIR}/json-3.11.3)
add_subdirectory(${THIRD_PARTY_DIR}/b64.c)
add_subdirectory(${THIRD_PARTY_DIR}/yaml-cpp)
add_custom_command(OUTPUT
${CMAKE_SOURCE_DIR}/tinyRPC/api/http_rule.pb.h
${CMAKE_SOURCE_DIR}/tinyRPC/api/http_rule.pb.cc
COMMAND protoc --cpp_out=. tinyRPC/api/http_rule.proto
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "compile http_rule.proto")
option(USE_SERVER_V1 "use server version v1" OFF)
if(USE_SERVER_V1)
message("using server version v1 (one io_context with multiply threads)")
add_definitions(-DUSE_SERVER_V1)
set(SERVER_SRCS
src/server/server.cc
src/server/session.cc
src/server/gw.cc)
else ()
message("using server version v2 (io_context per threads with ThreadPoolExecutor)")
set(SERVER_SRCS
src/server_v2/server.cc
src/server_v2/session.cc
src/server_v2/gw.cc)
endif ()
add_library(${PROJECT_NAME}
${SERVER_SRCS}
src/exec/task_queue.cc
src/exec/executor.cc
src/router/base_router.cc
src/router/protobuf_router.cc
src/router/http_router.cc
src/codec/abstract_codec.cc
src/codec/protobuf_codec.cc
src/codec/http_codec.cc
src/rpc/error.cc
src/rpc/controller.cc
src/rpc/message.cc
src/registry/etcd_def.cc
src/registry/etcd.cc
src/registry/registry.cc
src/client/client.cc
src/client/channel.cc
src/client/lb.cc
${CMAKE_SOURCE_DIR}/tinyRPC/api/http_rule.pb.cc)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_SOURCE_DIR}
${THIRD_PARTY_DIR}
${THIRD_PARTY_DIR}/asio)
target_link_libraries(${PROJECT_NAME} PRIVATE
nlohmann_json::nlohmann_json
yaml-cpp::yaml-cpp
b64c)
set(LIBS ${PROJECT_NAME} ${Protobuf_LIBRARY} pthread uuid)
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/tinyRPC/api
DESTINATION include/${PROJECT_NAME}
FILES_MATCHING
PATTERN "*.proto"
PATTERN "*.h"
PATTERN "*.cc" EXCLUDE)
add_subdirectory(plugin)
add_subdirectory(test)
add_subdirectory(example/calculate)
#add_subdirectory(example/http)
add_subdirectory(benchmark)
install(TARGETS protoc-gen-http-gw DESTINATION bin)