find_package(absl CONFIG REQUIRED PATHS /opt/grpc)
find_package(utf8_range CONFIG HINTS /opt/grpc REQUIRED)
find_package(protobuf CONFIG HINTS /opt/grpc REQUIRED)
find_package(gRPC CONFIG REQUIRED PATHS /opt/grpc)
find_package(Threads)
add_library(myproto ${PROTO_FILES})
target_link_libraries(myproto
PUBLIC
protobuf::libprotobuf
gRPC::grpc
gRPC::grpc++
)
target_include_directories(myproto PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
#
# Compile protobuf and grpc files in myproto target to cpp
get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin IMPORTED)
message("status cpp plugin ${grpc_cpp_plugin_location}")
protobuf_generate(TARGET myproto LANGUAGE cpp)
protobuf_generate(TARGET myproto LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}")