mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
added PROTOBUF_GENERATE_GRPC_CPP for generating grpc proto
This commit is contained in:
parent
bbd368cdac
commit
13643d825b
@ -323,6 +323,7 @@ endif()
|
|||||||
include (cmake/find/libxml2.cmake)
|
include (cmake/find/libxml2.cmake)
|
||||||
include (cmake/find/brotli.cmake)
|
include (cmake/find/brotli.cmake)
|
||||||
include (cmake/find/protobuf.cmake)
|
include (cmake/find/protobuf.cmake)
|
||||||
|
include (cmake/find/grpc.cmake)
|
||||||
include (cmake/find/pdqsort.cmake)
|
include (cmake/find/pdqsort.cmake)
|
||||||
include (cmake/find/hdfs3.cmake) # uses protobuf
|
include (cmake/find/hdfs3.cmake) # uses protobuf
|
||||||
include (cmake/find/consistent-hashing.cmake)
|
include (cmake/find/consistent-hashing.cmake)
|
||||||
|
57
cmake/find/grpc.cmake
Normal file
57
cmake/find/grpc.cmake
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
set(_PROTOBUF_PROTOC $<TARGET_FILE:protoc>)
|
||||||
|
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:grpc_cpp_plugin>)
|
||||||
|
|
||||||
|
function(PROTOBUF_GENERATE_GRPC_CPP SRCS HDRS)
|
||||||
|
if(NOT ARGN)
|
||||||
|
message(SEND_ERROR "Error: PROTOBUF_GENERATE_GRPC_CPP() called without any proto files")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
|
||||||
|
foreach(FIL ${ARGN})
|
||||||
|
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
||||||
|
get_filename_component(ABS_PATH ${ABS_FIL} PATH)
|
||||||
|
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
||||||
|
if(${_contains_already} EQUAL -1)
|
||||||
|
list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED PROTOBUF_IMPORT_DIRS)
|
||||||
|
foreach(DIR ${Protobuf_IMPORT_DIRS})
|
||||||
|
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
|
||||||
|
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
||||||
|
if(${_contains_already} EQUAL -1)
|
||||||
|
list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${SRCS})
|
||||||
|
set(${HDRS})
|
||||||
|
foreach(FIL ${ARGN})
|
||||||
|
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
||||||
|
get_filename_component(FIL_WE ${FIL} NAME_WE)
|
||||||
|
|
||||||
|
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.cc")
|
||||||
|
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.h")
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.cc"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.h"
|
||||||
|
COMMAND ${_PROTOBUF_PROTOC}
|
||||||
|
ARGS --grpc_out=${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
--plugin=protoc-gen-grpc=${_GRPC_CPP_PLUGIN_EXECUTABLE}
|
||||||
|
${_protobuf_include_path} ${ABS_FIL}
|
||||||
|
DEPENDS ${ABS_FIL}
|
||||||
|
COMMENT "Running gRPC C++ protocol buffer compiler on ${FIL}"
|
||||||
|
VERBATIM)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
|
||||||
|
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
|
||||||
|
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
|
||||||
|
endfunction()
|
@ -1479,4 +1479,5 @@ target_link_libraries(grpc_cpp_plugin
|
|||||||
${_gRPC_PROTOBUF_LIBRARIES}
|
${_gRPC_PROTOBUF_LIBRARIES}
|
||||||
${_gRPC_ALLTARGETS_LIBRARIES}
|
${_gRPC_ALLTARGETS_LIBRARIES}
|
||||||
grpc_plugin_support
|
grpc_plugin_support
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user