I'm trying to generate grpc cpp files but the generator plugin fails when I call it in cmake
find_package(protoc CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION) #get plugin location
get_target_property(protoc_location protobuf::protoc LOCATION) #for sanity check
message("protoc is at ${protoc_location}") #for sanity check
message("grpc plugin is at ${grpc_cpp_plugin_location}") #for sanity check
add_library(${PRO_NAME} ${PRO_SRCS} test.proto)
protobuf_generate(TARGET ${PRO_NAME} LANGUAGE cpp)
protobuf_generate(TARGET ${PRO_NAME} LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}")
Produces an error like
protoc is at /home/user/.conan/data/protoc_installer/...
grpc plugin is at /home/user/.conan/data/grpc/...
-- Configuring done
-- Generating done
-- Build files have been written to:
[ 16%] Running grpc protocol buffer compiler on test.proto
protoc-gen-grpc: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1
but if I use it manually in a shell script it works even though i copy the file path from the cmake output
PROTOC=${PATH FROM CMAKE}
GRPCC=${PATH FROM CMAKE}
$PROTOC -I src/ --grpc_out=. --plugin=protoc-gen-grpc=$GRPCC test.proto
basing method off of https://www.falkoaxmann.de/dev/2020/11/08/grpc-plugin-cmake-support.html
I initially thought my issue was a library path error, I'm using a remote build server with conan import management, but I verified that the plugins rpath includes the relative locations of the libraries it needs.