-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
CMakeLists.txt
187 lines (157 loc) · 6.99 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
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
add_custom_target(arrow_flight)
# Header files
arrow_install_all_headers("arrow/flight")
set(ARROW_FLIGHT_STATIC_LINK_LIBS
protobuf::libprotobuf
gRPC::grpc++
gRPC::grpc
gRPC::gpr
c-ares::cares)
if(WIN32)
list(APPEND ARROW_FLIGHT_STATIC_LINK_LIBS Ws2_32.lib)
endif()
if(GRPC_HAS_ADDRESS_SORTING)
list(APPEND ARROW_FLIGHT_STATIC_LINK_LIBS gRPC::address_sorting)
endif()
if(ARROW_TEST_LINKAGE STREQUAL "static")
set(ARROW_FLIGHT_TEST_LINK_LIBS arrow_flight_static arrow_flight_testing_static
${ARROW_TEST_STATIC_LINK_LIBS}
${ARROW_FLIGHT_STATIC_LINK_LIBS})
else()
set(ARROW_FLIGHT_TEST_LINK_LIBS arrow_flight_shared arrow_flight_testing_shared
${ARROW_TEST_SHARED_LINK_LIBS}
${ARROW_FLIGHT_STATIC_LINK_LIBS})
endif()
# TODO(wesm): Protobuf shared vs static linking
set(FLIGHT_PROTO_PATH "${ARROW_SOURCE_DIR}/../format")
set(FLIGHT_PROTO ${ARROW_SOURCE_DIR}/../format/Flight.proto)
set(FLIGHT_GENERATED_PROTO_FILES "${CMAKE_CURRENT_BINARY_DIR}/Flight.pb.cc"
"${CMAKE_CURRENT_BINARY_DIR}/Flight.pb.h"
"${CMAKE_CURRENT_BINARY_DIR}/Flight.grpc.pb.cc"
"${CMAKE_CURRENT_BINARY_DIR}/Flight.grpc.pb.h")
set(PROTO_DEPENDS ${FLIGHT_PROTO} protobuf::libprotobuf gRPC::grpc)
add_custom_command(OUTPUT ${FLIGHT_GENERATED_PROTO_FILES}
COMMAND protobuf::protoc "-I${FLIGHT_PROTO_PATH}"
"--cpp_out=${CMAKE_CURRENT_BINARY_DIR}" "${FLIGHT_PROTO}"
DEPENDS ${PROTO_DEPENDS} ARGS
COMMAND protobuf::protoc
"-I${FLIGHT_PROTO_PATH}"
"--grpc_out=${CMAKE_CURRENT_BINARY_DIR}"
"--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}"
"${FLIGHT_PROTO}")
set_source_files_properties(${FLIGHT_GENERATED_PROTO_FILES} PROPERTIES GENERATED TRUE)
add_custom_target(flight_grpc_gen ALL DEPENDS ${FLIGHT_GENERATED_PROTO_FILES})
# Note, we do not compile the generated Protobuf sources directly, instead
# compiling then via protocol-internal.cc which contains some gRPC template
# overrides to enable Flight-specific optimizations. See comments in
# protobuf-internal.cc
set(ARROW_FLIGHT_SRCS
client.cc
internal.cc
protocol-internal.cc
serialization-internal.cc
server.cc
server_auth.cc
types.cc)
add_arrow_lib(arrow_flight
OUTPUTS
ARROW_FLIGHT_LIBRARIES
SOURCES
${ARROW_FLIGHT_SRCS}
DEPENDENCIES
flight_grpc_gen
metadata_fbs
SHARED_LINK_FLAGS
${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
SHARED_LINK_LIBS
arrow_shared
${ARROW_FLIGHT_STATIC_LINK_LIBS}
STATIC_LINK_LIBS
arrow_static
${ARROW_FLIGHT_STATIC_LINK_LIBS})
foreach(LIB_TARGET ${ARROW_FLIGHT_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_EXPORTING)
endforeach()
# Define arrow_flight_testing library
if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
add_arrow_lib(arrow_flight_testing
OUTPUTS
ARROW_FLIGHT_TESTING_LIBRARIES
SOURCES
test-util.cc
DEPENDENCIES
GTest::GTest
flight_grpc_gen
arrow_dependencies
metadata_fbs
SHARED_LINK_LIBS
arrow_shared
arrow_flight_shared
arrow_testing_shared
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_SYSTEM_LIBRARY}
GTest::GTest
STATIC_LINK_LIBS
arrow_static
arrow_flight_static
arrow_testing_static)
endif()
foreach(LIB_TARGET ${ARROW_FLIGHT_TESTING_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_EXPORTING)
endforeach()
add_arrow_test(flight-test
EXTRA_LINK_LIBS
${ARROW_FLIGHT_TEST_LINK_LIBS}
LABELS
"arrow_flight")
# Build test server for unit tests or benchmarks
if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
add_executable(flight-test-server test-server.cc)
target_link_libraries(flight-test-server ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
add_executable(flight-test-integration-server test-integration-server.cc)
target_link_libraries(flight-test-integration-server ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
add_executable(flight-test-integration-client test-integration-client.cc)
target_link_libraries(flight-test-integration-client ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
# This is needed for the unit tests
if(ARROW_BUILD_TESTS)
add_dependencies(arrow-flight-test flight-test-server)
endif()
add_dependencies(arrow_flight flight-test-server flight-test-integration-client
flight-test-integration-server)
endif()
if(ARROW_BUILD_BENCHMARKS)
# Perf server for benchmarks
set(PERF_PROTO_GENERATED_FILES "${CMAKE_CURRENT_BINARY_DIR}/perf.pb.cc"
"${CMAKE_CURRENT_BINARY_DIR}/perf.pb.h")
add_custom_command(OUTPUT ${PERF_PROTO_GENERATED_FILES}
COMMAND protobuf::protoc "-I${CMAKE_CURRENT_SOURCE_DIR}"
"--cpp_out=${CMAKE_CURRENT_BINARY_DIR}" "perf.proto"
DEPENDS ${PROTO_DEPENDS})
add_executable(arrow-flight-perf-server perf-server.cc perf.pb.cc)
target_link_libraries(arrow-flight-perf-server ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
add_executable(arrow-flight-benchmark flight-benchmark.cc perf.pb.cc)
target_link_libraries(arrow-flight-benchmark ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
add_dependencies(arrow-flight-benchmark arrow-flight-perf-server)
add_dependencies(arrow_flight arrow-flight-benchmark)
endif(ARROW_BUILD_BENCHMARKS)