blob: e68a2c9a54d6a6b65cfe9ab31feda6306507190d (
plain)
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
|
# DEPENDENCIES
##############
# Require at least Protobuf 3 for gNMI
find_package(Protobuf 3.0.0 REQUIRED) #official cmake module
include_directories(${PROTOBUF_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
message(STATUS "Using protobuf ${protobuf_VERSION}")
# Require at least gRPC 1.12.0, maybe earlier can be used
# Official gRPCConfig.cmake installed by gRPC only if compiled with cmake
# Use our own FindGRPC.cmake instead
find_package(GRPC 1.12.0 REQUIRED)
get_filename_component(gnmi_proto "gnmi.proto" ABSOLUTE)
get_filename_component(gnmi_ext_proto "gnmi_ext.proto" ABSOLUTE)
# GENERATION OF SOURCE FILES
############################
# Official generator
protobuf_generate_cpp(gnmi_proto_srcs gnmi_proto_hdrs ${gnmi_proto})
protobuf_generate_cpp(gnmi_ext_proto_srcs gnmi_ext_proto_hdrs ${gnmi_ext_proto})
# Custom generator: Official `protobuf_generate_cpp` can't use grpc plugins
PROTOBUF_GENERATE_GRPC_CPP(gnmi_grpc_srcs gnmi_grpc_hdrs ${gnmi_proto})
PROTOBUF_GENERATE_GRPC_CPP(gnmi_ext_grpc_srcs gnmi_ext_grpc_hdrs ${gnmi_ext_proto})
# LINK OPTIONS FOR GNMI-SERVER
##############################
# Include generated protobuf C++ files
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
#Create a new library named gnmi
add_library(gnmi ${gnmi_grpc_srcs} ${gnmi_ext_grpc_srcs} ${gnmi_proto_srcs} ${gnmi_ext_proto_srcs})
#Link our new gnmi library with grpc and protobuf libraries
target_link_libraries(gnmi ${GRPCPP_LIBRARY} ${PROTOBUF_LIBRARIES})
|