[PATCH] D85815: [clangd] Warn developers when trying to link system-installed gRPC statically

Kirill Bobyrev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 01:21:26 PDT 2020


kbobyrev updated this revision to Diff 285577.
kbobyrev marked 3 inline comments as done.
kbobyrev added a comment.

Address post-LGTM comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85815/new/

https://reviews.llvm.org/D85815

Files:
  llvm/cmake/modules/FindGRPC.cmake


Index: llvm/cmake/modules/FindGRPC.cmake
===================================================================
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -1,8 +1,9 @@
-# This setup requires gRPC to be built from sources using CMake and installed to
-# ${GRPC_INSTALL_PATH} via -DCMAKE_INSTALL_PREFIX=${GRPC_INSTALL_PATH}.
 # FIXME(kirillbobyrev): Check if gRPC and Protobuf headers can be included at
 # configure time.
 if (GRPC_INSTALL_PATH)
+  # This setup requires gRPC to be built from sources using CMake and installed
+  # to ${GRPC_INSTALL_PATH} via -DCMAKE_INSTALL_PREFIX=${GRPC_INSTALL_PATH}.
+  # gRPC and Protobuf will be linked statically.
   set(protobuf_MODULE_COMPATIBLE TRUE)
   find_package(Protobuf CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
   message(STATUS "Using protobuf ${protobuf_VERSION}")
@@ -21,10 +22,17 @@
   set(GRPC_CPP_PLUGIN $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
 else()
+  # This setup requires system-installed gRPC and Protobuf.
+  # We always link dynamically in this mode. While the static libraries are
+  # usually installed, the CMake files telling us *which* static libraries to
+  # link are not.
+  if (NOT BUILD_SHARED_LIBS)
+    message(NOTICE "gRPC and Protobuf will be linked dynamically. If you want static linking, build gRPC from sources.")
+  endif()
   find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin)
   find_program(PROTOC protoc)
   if (GRPC_CPP_PLUGIN-NOTFOUND OR PROTOC-NOTFOUND)
-    message(FATAL_ERROR "gRPC C++ Plugin and Protoc must be on $PATH for Clangd remote index build")
+    message(FATAL_ERROR "gRPC C++ Plugin and Protoc must be on $PATH for Clangd remote index build.")
   endif()
   # On macOS the libraries are typically installed via Homebrew and are not on
   # the system path.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85815.285577.patch
Type: text/x-patch
Size: 1835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200814/a87d80a6/attachment.bin>


More information about the llvm-commits mailing list