Newer
Older
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
function(target_proto_generate)
cmake_parse_arguments(
PROTO
""
"TARGET;GEN_DIR;SRC_DIR"
"DEFINITIONS"
${ARGN}
)
message(STATUS "proto target: ${PROTO_TARGET}")
message(STATUS " proto output dir: ${PROTO_GEN_DIR}")
message(STATUS " proto src dir: ${PROTO_SRC_DIR}")
# FIXME: remove hardcoded googleapis include below
foreach (proto ${PROTO_DEFINITIONS})
get_filename_component(_proto ${proto} ABSOLUTE)
get_filename_component(_proto_path "${_proto}" PATH)
get_filename_component(_proto_name ${proto} NAME_WLE)
string(REPLACE ${PROTO_SRC_DIR} ${PROTO_GEN_DIR} _proto_gen_path ${_proto_path})
message(STATUS " proto generate [${_proto_name}] from ${_proto} to ${_proto_gen_path}")
# Generated sources
set(_proto_src "${_proto_gen_path}/${_proto_name}.pb.cc")
set(_proto_hdr "${_proto_gen_path}/${_proto_name}.pb.h")
add_custom_command(
OUTPUT "${_proto_src}" "${_proto_hdr}"
COMMAND ${PROTOBUF_PROTOC}
ARGS
--cpp_out "${PROTO_GEN_DIR}"
--proto_path "${PROTO_SRC_DIR}"
-I "${_proto_path}"
-I "${CMAKE_SOURCE_DIR}/src/vereign/proto/googleapis"
"${_proto}"
DEPENDS "${_proto}")
target_sources(${PROTO_TARGET} PRIVATE ${_proto_src})
endforeach()
endfunction()
function(target_grpc_generate)
cmake_parse_arguments(
PROTO
""
"TARGET;GEN_DIR;SRC_DIR"
"DEFINITIONS"
${ARGN}
)
message(STATUS "grpc target: ${PROTO_TARGET}")
message(STATUS " grpc output dir: ${PROTO_GEN_DIR}")
message(STATUS " grpc src dir: ${PROTO_SRC_DIR}")
# FIXME: remove hardcoded googleapis include below
foreach (proto ${PROTO_DEFINITIONS})
get_filename_component(_proto ${proto} ABSOLUTE)
get_filename_component(_proto_path "${_proto}" PATH)
get_filename_component(_proto_name ${proto} NAME_WLE)
string(REPLACE ${PROTO_SRC_DIR} ${PROTO_GEN_DIR} _proto_gen_path ${_proto_path})
message(STATUS " grpc generate [${_proto_name}] from ${_proto} to ${_proto_gen_path}")
# Generated sources
set(_proto_src "${_proto_gen_path}/${_proto_name}.grpc.pb.cc")
set(_proto_hdr "${_proto_gen_path}/${_proto_name}.grpc.pb.h")
add_custom_command(
OUTPUT "${_proto_src}" "${_proto_hdr}"
COMMAND ${PROTOBUF_PROTOC}
ARGS
--grpc_out "${PROTO_GEN_DIR}"
--cpp_out "${PROTO_GEN_DIR}"
--proto_path "${PROTO_SRC_DIR}"
-I "${_proto_path}"
-I "${CMAKE_SOURCE_DIR}/src/vereign/proto/googleapis"
--plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN_EXECUTABLE}"
"${_proto}"
DEPENDS "${_proto}")
target_sources(${PROTO_TARGET} PRIVATE ${_proto_src})
endforeach()
endfunction()