lordgamez commented on code in PR #1698:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1698#discussion_r1452555861


##########
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:
   The grafana-loki-protos is the target to generate the protobuf cpp files, 
the minifi-grafana-loki target should depend on that, but you are right the 
other targets should not be included in the dependencies, updated in 
407abbc65a8900dc9937dc0587c52d68693335ff



-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to