adamdebreceni commented on code in PR #1698:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1698#discussion_r1447307752
##########
extensions/grafana-loki/CMakeLists.txt:
##########
@@ -16,20 +16,46 @@
# specific language governing permissions and limitations
# under the License.
#
-
if (NOT (ENABLE_ALL OR ENABLE_GRAFANA_LOKI))
return()
endif()
include(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt)
-file(GLOB SOURCES "*.cpp")
+if (ENABLE_GRPC)
+ include(Grpc)
-add_library(minifi-grafana-loki SHARED ${SOURCES})
+ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated)
+
+ add_custom_command(
+ OUTPUT
${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/grafana-loki-push.grpc.pb.cc
${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/grafana-loki-push.grpc.pb.h
${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/grafana-loki-push.pb.h
${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/grafana-loki-push.pb.cc
+ COMMAND ${PROTOBUF_COMPILER}
--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}
-I=${CMAKE_CURRENT_SOURCE_DIR}/protos/ -I=${protobuf_SOURCE_DIR}/src
--grpc_out=${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/
--cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/
${CMAKE_CURRENT_SOURCE_DIR}/protos/grafana-loki-push.proto
+ DEPENDS protobuf::protoc grpc_cpp_plugin)
+ add_custom_target(grafana-loki-protos ALL DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/grafana-loki-push.grpc.pb.cc
${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/grafana-loki-push.grpc.pb.h
${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/grafana-loki-push.pb.h
${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/grafana-loki-push.pb.cc)
+
+ file(GLOB SOURCES "*.cpp")
+ list(APPEND SOURCES
+
${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/grafana-loki-push.grpc.pb.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/protobuf-generated/grafana-loki-push.pb.cc
+ )
+else()
+ set(SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/PushGrafanaLoki.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/PushGrafanaLokiREST.cpp
+ )
+endif()
+
+add_library(minifi-grafana-loki SHARED ${SOURCES})
target_include_directories(minifi-grafana-loki PRIVATE BEFORE
"${CMAKE_SOURCE_DIR}/extensions/http-curl")
-target_link_libraries(minifi-grafana-loki ${LIBMINIFI})
-target_link_libraries(minifi-grafana-loki minifi-http-curl)
+target_link_libraries(minifi-grafana-loki ${LIBMINIFI} minifi-http-curl)
+add_dependencies(minifi-grafana-loki minifi-http-curl)
+
+if (ENABLE_GRPC)
+ target_include_directories(minifi-grafana-loki PRIVATE BEFORE
"${GRPC_INCLUDE_DIR}" "${PROTOBUF_INCLUDE_DIR}")
+ target_link_libraries(minifi-grafana-loki grpc++ protobuf::libprotobuf)
+ add_dependencies(minifi-grafana-loki grpc grpc++ protobuf::libprotobuf
grafana-loki-protos)
Review Comment:
is the `grpc++` and `protobuf::libprotobuf` dependency already handled by
`target_link_libraries`?
--
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]