wgtmac commented on code in PR #2416:
URL: https://github.com/apache/orc/pull/2416#discussion_r2387329250


##########
cmake_modules/ThirdpartyToolchain.cmake:
##########
@@ -155,6 +183,111 @@ ExternalProject_Add (orc-format_ep
   TEST_COMMAND     ""
 )
 
+# ----------------------------------------------------------------------
+# Protobuf
+#
+# XXX: It must be processed before ZLIB, otherwise ZLIB_LIBRARIES will 
interfere with building protobuf.
+
+if (ORC_PACKAGE_KIND STREQUAL "conan")
+  find_package (Protobuf REQUIRED CONFIG)
+  add_library (orc_protobuf INTERFACE)
+  target_link_libraries(orc_protobuf INTERFACE protobuf::protobuf)
+  list (APPEND ORC_SYSTEM_DEPENDENCIES Protobuf)
+  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:protobuf::protobuf>")
+elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
+  find_package(Protobuf CONFIG REQUIRED)
+  add_library (orc_protobuf INTERFACE IMPORTED)
+  target_link_libraries(orc_protobuf INTERFACE protobuf::libprotobuf)
+  list (APPEND ORC_SYSTEM_DEPENDENCIES Protobuf)
+  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:protobuf::libprotobuf>")
+  set (PROTOBUF_EXECUTABLE protobuf::protoc)
+elseif (NOT "${PROTOBUF_HOME}" STREQUAL "")
+  find_package (ProtobufAlt REQUIRED)
+
+  if (ORC_PREFER_STATIC_PROTOBUF AND PROTOBUF_STATIC_LIB)
+    orc_add_resolved_library (orc_protobuf ${PROTOBUF_STATIC_LIB} 
${PROTOBUF_INCLUDE_DIR})
+  else ()
+    orc_add_resolved_library (orc_protobuf ${PROTOBUF_LIBRARY} 
${PROTOBUF_INCLUDE_DIR})
+  endif ()
+
+  if (ORC_PREFER_STATIC_PROTOBUF AND PROTOC_STATIC_LIB)
+    orc_add_resolved_library (orc_protoc ${PROTOC_STATIC_LIB} 
${PROTOBUF_INCLUDE_DIR})
+  else ()
+    orc_add_resolved_library (orc_protoc ${PROTOC_LIBRARY} 
${PROTOBUF_INCLUDE_DIR})
+  endif ()
+
+  list (APPEND ORC_SYSTEM_DEPENDENCIES ProtobufAlt)
+  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:protobuf::libprotobuf>")
+  orc_provide_find_module (ProtobufAlt)
+else ()
+  prepare_fetchcontent()

Review Comment:
   Good suggestion! I've switched to use blocks.



-- 
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]

Reply via email to