I've followed instructions on the gRPC site's quickstart
https://grpc.io/docs/languages/cpp/quickstart/
I've also successfully built their HelloWorld example in their build tree,
using their cmake files.
Now I want to build my own HelloWorld project outside of their build, using
an already built and installed gRPC, to show that I will be able to build
an actual project.
I've copy pasted most of their cmake, but I am getting an error:
====================[ Build | gRPC_demo | Debug
]===============================
/usr/bin/cmake3 --build
/home/cpisz/git-workspace/gRPC_demo/cmake-build-debug --target gRPC_demo --
-j 12 gmake[3]:
*** No rule to make target '/protos/helloworld.proto', needed by
'helloworld.pb.cc'. Stop. gmake[2]: *** [CMakeFiles/Makefile2:95:
CMakeFiles/gRPC_demo.dir/all] Error 2 gmake[1]: ***
[CMakeFiles/Makefile2:103: CMakeFiles/gRPC_demo.dir/rule] Error 2 gmake:
*** [Makefile:138: gRPC_demo] Error 2
-----------------------
My build tree looks like:
gRPC_demo
protos
helloworld.proto
main.cpp
CMakeLists.txt
----------------------
The cmake contents look like:
cmake_minimum_required(VERSION 3.5.1)
project(gRPC_demo)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
# Threads
find_package(Threads REQUIRED)
# Protobuf
set(protobuf_MODULE_COMPATIBLE TRUE)
find_package(Protobuf CONFIG REQUIRED)
message(STATUS "Using protobuf ${protobuf_VERSION}")
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
set(_REFLECTION gRPC::grpc++_reflection)
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
# gRPC
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
set(_GRPC_GRPCPP gRPC::grpc++)
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
# Proto file
get_filename_component(hw_proto "/protos/helloworld.proto" ABSOLUTE)
get_filename_component(hw_proto_path "${hw_proto}" PATH)
# Generated sources
set(hw_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.cc")
set(hw_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.h")
set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc")
set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.h")
add_custom_command(
OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}" "${hw_grpc_srcs}"
"${hw_grpc_hdrs}"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
-I "${hw_proto_path}"
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
"${hw_proto}"
DEPENDS "${hw_proto}")
# Include generated *.pb.h files
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
# Target
add_executable(gRPC_demo
main.cpp
${hw_proto_srcs}
${hw_grpc_srcs}
)
target_link_libraries(gRPC_demo
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
)
----------
I am pretty new to using cmake. What am I doing wrong?
--
You received this message because you are subscribed to the Google Groups
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/c5dea383-1530-4a9a-9850-2e5539d30173n%40googlegroups.com.