|
|
@@ -55,8 +55,9 @@ add_test(NAME test_desc COMMAND test_desc ${DESC_PROTO_DESC})
|
|
|
|
|
|
if(CMake_TEST_FindProtobuf_gRPC)
|
|
|
find_program(gRPC_CPP_PLUGIN grpc_cpp_plugin)
|
|
|
- add_library(msgs_grpc msgs/example_service.proto)
|
|
|
- target_include_directories(msgs_grpc PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
+ add_library(msgs_grpc msgs/grpc/example_service.proto)
|
|
|
+ # NOTE: by default generated files will be placed under ${CMAKE_CURRENT_BINARY_DIR}/msgs/grpc/
|
|
|
+ target_include_directories(msgs_grpc PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/msgs/grpc/)
|
|
|
target_link_libraries(msgs_grpc PUBLIC ${Protobuf_LIBRARIES})
|
|
|
protobuf_generate(TARGET msgs_grpc LANGUAGE cpp)
|
|
|
protobuf_generate(TARGET msgs_grpc LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc PLUGIN "protoc-gen-grpc=${gRPC_CPP_PLUGIN}")
|
|
|
@@ -64,4 +65,24 @@ if(CMake_TEST_FindProtobuf_gRPC)
|
|
|
add_executable(test_generate_grpc main-generate-grpc.cxx)
|
|
|
target_link_libraries(test_generate_grpc PRIVATE msgs_grpc)
|
|
|
add_test(NAME test_generate_grpc COMMAND test_generate_grpc)
|
|
|
+
|
|
|
+ add_library(msgs_grpc_IMPORT_DIRS msgs/grpc/example_service.proto)
|
|
|
+ # NOTE: with IMPORT_DIRS msgs/, generated files will be placed under ${CMAKE_CURRENT_BINARY_DIR}/grpc/
|
|
|
+ target_include_directories(msgs_grpc_IMPORT_DIRS PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/grpc/)
|
|
|
+ target_link_libraries(msgs_grpc_IMPORT_DIRS PUBLIC ${Protobuf_LIBRARIES})
|
|
|
+ protobuf_generate(TARGET msgs_grpc_IMPORT_DIRS LANGUAGE cpp IMPORT_DIRS msgs/)
|
|
|
+ protobuf_generate(TARGET msgs_grpc_IMPORT_DIRS LANGUAGE grpc IMPORT_DIRS msgs/ GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc PLUGIN "protoc-gen-grpc=${gRPC_CPP_PLUGIN}")
|
|
|
+ add_executable(test_generate_grpc_IMPORT_DIRS main-generate-grpc.cxx)
|
|
|
+ target_link_libraries(test_generate_grpc_IMPORT_DIRS PRIVATE msgs_grpc_IMPORT_DIRS)
|
|
|
+ add_test(NAME test_generate_grpc_IMPORT_DIRS COMMAND test_generate_grpc_IMPORT_DIRS)
|
|
|
+
|
|
|
+ add_library(msgs_grpc_APPEND_PATH msgs/grpc/example_service.proto)
|
|
|
+ # NOTE: with APPEND_PATH, generated files will be placed under ${CMAKE_CURRENT_BINARY_DIR}/
|
|
|
+ target_include_directories(msgs_grpc_APPEND_PATH PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
+ target_link_libraries(msgs_grpc_APPEND_PATH PUBLIC ${Protobuf_LIBRARIES})
|
|
|
+ protobuf_generate(TARGET msgs_grpc_APPEND_PATH LANGUAGE cpp APPEND_PATH)
|
|
|
+ protobuf_generate(TARGET msgs_grpc_APPEND_PATH LANGUAGE grpc APPEND_PATH GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc PLUGIN "protoc-gen-grpc=${gRPC_CPP_PLUGIN}")
|
|
|
+ add_executable(test_generate_grpc_APPEND_PATH main-generate-grpc.cxx)
|
|
|
+ target_link_libraries(test_generate_grpc_APPEND_PATH PRIVATE msgs_grpc_APPEND_PATH)
|
|
|
+ add_test(NAME test_generate_grpc_APPEND_PATH COMMAND test_generate_grpc_APPEND_PATH)
|
|
|
endif()
|