I have a working example of building a grpc library in C++ using CMake.
However I need to hardcode the absolute path to the flag
--plugin=protoc-gen-grpc="/home/myusername/dev/lab/MiniGL/vcpkg/installed/x64-linux/tools/grpc/grpc_cpp_plugin"
What I really would like to do is to find something like the environment variable ${PROTOBUF_PROTOC_EXECUTABLE}
below for the grpc_cpp_plugin that is required but I just can't find it. i.e. ${GPRC_CPP_PLUGIN_EXECUTABLE}
Does anyone know if I have missed something simple here?
This is my entire listing of the CMakeLists.txt
project(hello_contract_library)
set(CMAKE_VERBOSE_MAKEFILE ON)
find_package(protobuf CONFIG REQUIRED)
#target_link_libraries(main PRIVATE protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite)
set(GENERATED_DIR "${PROJECT_SOURCE_DIR}/generated")
file(MAKE_DIRECTORY "${GENERATED_DIR}")
set(hello_src "${GENERATED_DIR}/hello.pb.cc")
set(hello_hdr "${GENERATED_DIR}/hello.pb.h")
set(hello_grpc_src "${GENERATED_DIR}/hello.grpc.pb.cc")
set(hello_grpc_hdr "${GENERATED_DIR}/hello.grpc.pb.h")
# Added to include generated header files
include_directories("${GENERATED_DIR}")
add_custom_command(
OUTPUT "${hello_src}" "${hello_hdr}" "${hello_grpc_src}" "${hello_grpc_hdr}"
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS --grpc_out "${PROJECT_SOURCE_DIR}/generated"
--cpp_out "${PROJECT_SOURCE_DIR}/generated"
-I "/home/myusername/dev/lab/MiniGL/src/backend/public/contracts"
--plugin=protoc-gen-grpc="/home/myusername/dev/lab/MiniGL/vcpkg/installed/x64-linux/tools/grpc/grpc_cpp_plugin"
"hello.proto"
DEPENDS "hello.proto")
add_library(${PROJECT_NAME}
${hello_src}
${hello_hdr}
${hello_grpc_src}
${hello_grpc_hdr})