-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
210 lines (189 loc) · 6.05 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
cmake_minimum_required(VERSION 3.5.1)
project(grpc-perf C CXX)
option(INCLUDE_GRPC_SIDEBAND "Include support for profiling gprc sideband tests" OFF)
option(INCLUDE_FLAATBUFFERS "Include support for profiling Flatbuffers" OFF)
option(INCLUDE_UDS_TESTS "Include support for testing performance over UDS (Unix Domain Sockets)" ON)
include(FetchContent)
set(FETCHCONTENT_QUIET OFF)
set(protobuf_INSTALL OFF)
set(utf8_range_ENABLE_INSTALL OFF)
set(ABSL_ENABLE_INSTALL OFF)
# gRPC components
FetchContent_Declare(
gRPC
GIT_REPOSITORY https://github.com/grpc/grpc
GIT_TAG v1.68.2
)
FetchContent_MakeAvailable(gRPC)
# cxxopts components
FetchContent_Declare(
cxxopts
GIT_REPOSITORY https://github.com/jarro2783/cxxopts
GIT_TAG v3.2.0
)
FetchContent_MakeAvailable(cxxopts)
# grpc-sideband components
if (INCLUDE_GRPC_SIDEBAND)
set(INCLUDE_SIDEBAND_RDMA OFF)
FetchContent_Declare(
grpc-sideband
GIT_REPOSITORY https://github.com/ni/grpc-sideband
GIT_TAG v0.1
)
FetchContent_MakeAvailable(grpc-sideband)
endif()
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-shlib-undefined")
else()
cmake_policy(SET CMP0091 NEW)
add_definitions(-D_WIN32_WINNT=0x600 -bigobj)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4244 /wd4018")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
if (INCLUDE_GRPC_SIDEBAND)
add_definitions(-DENABLE_GRPC_SIDEBAND)
endif()
if (INCLUDE_FLAATBUFFERS)
add_definitions(-DENABLE_FLATBUFFERS)
endif()
if (INCLUDE_UDS_TESTS)
add_definitions(-DENABLE_UDS_TESTS)
endif()
find_package(Threads REQUIRED)
link_directories(.)
# Use the grpc targets directly from this build.
set(_PROTOBUF_LIBPROTOBUF libprotobuf)
set(_REFLECTION grpc++_reflection)
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
set(_GRPC_GRPCPP grpc++)
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:grpc_cpp_plugin>)
#----------------------------------------------------------------------
# Define libraries to link
#----------------------------------------------------------------------
#if (INCLUDE_GRPC_SIDEBAND)
# if(WIN32)
# link_directories("./third_party/grpc-sideband")
# else()
# # Add grpc-sideband deps here
# link_directories("./third_party/grpc-sideband/linux")
# endif()
#endif()
# Proto file
get_filename_component(datamoniker_proto "data_moniker.proto" ABSOLUTE)
get_filename_component(datamoniker_proto_path "${datamoniker_proto}" PATH)
# Generated data moniker sources
set(datamoniker_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/data_moniker.pb.cc")
set(datamoniker_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/data_moniker.pb.h")
set(datamoniker_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/data_moniker.grpc.pb.cc")
set(datamoniker_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/data_moniker.grpc.pb.h")
add_custom_command(
OUTPUT "${datamoniker_proto_srcs}" "${datamoniker_proto_hdrs}" "${datamoniker_grpc_srcs}" "${datamoniker_grpc_hdrs}"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
-I "${datamoniker_proto_path}" -I "${grpc_SOURCE_DIR}/third_party/protobuf/src"
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
"${datamoniker_proto}"
DEPENDS "${datamoniker_proto}")
# Proto file
get_filename_component(perftest_proto "perftest.proto" ABSOLUTE)
get_filename_component(perftest_proto_path "${perftest_proto}" PATH)
# Generated sources
set(perftest_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/perftest.pb.cc")
set(perftest_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/perftest.pb.h")
set(perftest_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/perftest.grpc.pb.cc")
set(perftest_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/perftest.grpc.pb.h")
add_custom_command(
OUTPUT "${perftest_proto_srcs}" "${perftest_proto_hdrs}" "${perftest_grpc_srcs}" "${perftest_grpc_hdrs}"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
-I "${perftest_proto_path}" -I "${grpc_SOURCE_DIR}/third_party/protobuf/src"
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
"${perftest_proto}"
DEPENDS "${perftest_proto}")
include_directories(
"${CMAKE_CURRENT_BINARY_DIR}"
"./src"
"/snap/flatbuffers/current/include"
"${cxxopts_SOURCE_DIR}/include")
# perftest gRPC Server
add_executable(perftest_server
src/perftest_server.cc
src/perftest_server_app.cc
src/client_utilities.cc
src/performance_tests.cc
${perftest_proto_srcs}
${perftest_grpc_srcs}
${datamoniker_proto_srcs}
${datamoniker_grpc_srcs}
)
if (INCLUDE_GRPC_SIDEBAND)
target_link_libraries(perftest_server
ni_grpc_sideband
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
${DETOURS_LIB}
)
else()
target_link_libraries(perftest_server
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
${DETOURS_LIB}
)
endif()
# localhost performance checking app
add_executable(local_perf_check
src/perftest_server.cc
src/localhost_perf_check.cc
src/client_utilities.cc
src/performance_tests.cc
${perftest_proto_srcs}
${perftest_grpc_srcs}
${datamoniker_proto_srcs}
${datamoniker_grpc_srcs}
)
if (INCLUDE_GRPC_SIDEBAND)
target_link_libraries(local_perf_check
ni_grpc_sideband
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
${DETOURS_LIB}
)
else()
target_link_libraries(local_perf_check
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
${DETOURS_LIB}
)
endif()
install(FILES $<TARGET_RUNTIME_DLLS:local_perf_check> TYPE BIN)
# Performance testing client
add_executable(perftest_client
src/perftest_client.cc
src/client_utilities.cc
src/performance_tests.cc
${perftest_proto_srcs}
${perftest_grpc_srcs}
${datamoniker_proto_srcs}
${datamoniker_grpc_srcs}
)
if (INCLUDE_GRPC_SIDEBAND)
target_link_libraries(perftest_client
ni_grpc_sideband
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
)
else()
target_link_libraries(perftest_client
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
)
endif()