The gRPC C++ examples use this common CMake file that has an option to fetch gRPC using CMake FetchContent instead of installing locally. This works for me, except that I can't figure out how to access the well known protobuf types from the protobuf submodule.
For example, I added this to the helloworld.proto example:
import "google/protobuf/empty.proto";
and get:
google/protobuf/empty.proto: File not found. helloworld.proto:17:1: Import "google/protobuf/empty.proto" was not found or had errors. make[2]: *** [helloworld.pb.cc] Error 1 make[1]: *** [CMakeFiles/hw_grpc_proto.dir/all] Error 2 make: *** [all] Error 2empty.proto is in ./_deps/grpc-src/third_party/protobuf/src/google/protobuf/.
Is there something I can add to the CMake file to have this work?