cyb70289 commented on a change in pull request #11524:
URL: https://github.com/apache/arrow/pull/11524#discussion_r737116654
##########
File path: cpp/examples/arrow/CMakeLists.txt
##########
@@ -15,30 +15,80 @@
# specific language governing permissions and limitations
# under the License.
-ADD_ARROW_EXAMPLE(row_wise_conversion_example)
+add_arrow_example(row_wise_conversion_example)
-if (ARROW_COMPUTE)
- ADD_ARROW_EXAMPLE(compute_register_example)
+if(ARROW_COMPUTE)
+ add_arrow_example(compute_register_example)
endif()
-if (ARROW_COMPUTE AND ARROW_CSV)
- ADD_ARROW_EXAMPLE(compute_and_write_csv_example)
+if(ARROW_COMPUTE AND ARROW_CSV)
+ add_arrow_example(compute_and_write_csv_example)
endif()
-if (ARROW_PARQUET AND ARROW_DATASET)
- if (ARROW_BUILD_SHARED)
+if(ARROW_FLIGHT)
+ if(ARROW_BUILD_SHARED)
+ set(FLIGHT_EXAMPLES_LINK_LIBS arrow_flight_shared)
+ else()
+ set(FLIGHT_EXAMPLES_LINK_LIBS arrow_flight_static)
+ endif()
+
+ set(FLIGHT_EXAMPLE_GENERATED_PROTO_FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.cc"
+ "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc"
+ "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.h")
+ set_source_files_properties(${FLIGHT_EXAMPLE_GENERATED_PROTO_FILES}
PROPERTIES GENERATED
+
TRUE)
+
+ set(FLIGHT_EXAMPLE_PROTO "helloworld.proto")
+ set(FLIGHT_EXAMPLE_PROTO_PATH "${CMAKE_CURRENT_LIST_DIR}")
+ set(FLIGHT_EXAMPLE_PROTO_DEPENDS ${FLIGHT_EXAMPLE_PROTO}
${ARROW_PROTOBUF_LIBPROTOBUF}
+ gRPC::grpc_cpp_plugin)
+
+ add_custom_command(OUTPUT ${FLIGHT_EXAMPLE_GENERATED_PROTO_FILES}
+ COMMAND ${ARROW_PROTOBUF_PROTOC}
"-I${FLIGHT_EXAMPLE_PROTO_PATH}"
+ "--cpp_out=${CMAKE_CURRENT_BINARY_DIR}"
+ "${FLIGHT_EXAMPLE_PROTO}"
+ DEPENDS ${PROTO_EXAMPLE_PROTO_DEPENDS} ARGS
+ COMMAND ${ARROW_PROTOBUF_PROTOC}
"-I${FLIGHT_EXAMPLE_PROTO_PATH}"
+ "--grpc_out=${CMAKE_CURRENT_BINARY_DIR}"
+
"--plugin=protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin>"
+ "${FLIGHT_EXAMPLE_PROTO}")
+
+ add_custom_target(flight_grpc_example_gen ALL
+ DEPENDS ${FLIGHT_EXAMPLE_GENERATED_PROTO_FILES})
+
+ add_arrow_example(flight_grpc_example
+ DEPENDENCIES
+ flight_grpc_example_gen
+ # Not CMAKE_CURRENT_BINARY_DIR so we can #include
+ # "examples/arrow/helloworld.pb.h" instead of
+ # "helloworld.pb.h" (which fails lint)
+ EXTRA_INCLUDES
+ ${CMAKE_BINARY_DIR}
+ EXTRA_LINK_LIBS
+ ${FLIGHT_EXAMPLES_LINK_LIBS}
+ gRPC::grpc++
+ gRPC::grpc++_reflection
Review comment:
Looks cmake cannot file gRPC::grpc++_reflection for *bundled* gRPC?
```
CMake Error at cmake_modules/BuildUtils.cmake:828 (add_executable):
Target "flight_grpc_example" links to target "gRPC::grpc++_reflection" but
the target was not found. Perhaps a find_package() call is missing for an
IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
examples/arrow/CMakeLists.txt:61 (add_arrow_example)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]