[PATCH] D141047: build: with -DCLANGD_ENABLE_REMOTE=ON, search for grpc++ dependencies too

Sylvestre Ledru via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 5 05:59:55 PST 2023


sylvestre.ledru created this revision.
sylvestre.ledru added a reviewer: serge-sans-paille.
Herald added subscribers: bmahjour, kadircet, arphaman.
Herald added a project: All.
sylvestre.ledru requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Fixes: https://github.com/llvm/llvm-project/issues/59844


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141047

Files:
  clang/cmake/modules/AddGRPC.cmake
  cmake/Modules/FindGRPC.cmake


Index: cmake/Modules/FindGRPC.cmake
===================================================================
--- cmake/Modules/FindGRPC.cmake
+++ cmake/Modules/FindGRPC.cmake
@@ -82,11 +82,28 @@
     endif()
   endif()
   if(NOT TARGET grpc++)
+    find_library(GPR_LIBRARY gpr $GRPC_OPTS REQUIRED)
+    add_library(gpr UNKNOWN IMPORTED GLOBAL)
+    message(STATUS "Using gpr: " ${GPR_LIBRARY})
+    set_target_properties(gpr PROPERTIES IMPORTED_LOCATION ${GPR_LIBRARY})
+
     find_library(GRPC_LIBRARY grpc++ ${GRPC_OPTS} REQUIRED)
     add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
     message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
     set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
     target_include_directories(grpc++ INTERFACE ${GRPC_INCLUDE_PATHS})
+    find_library(GRPC2_LIBRARY grpc $GRPC_OPTS REQUIRED)
+    add_library(grpc UNKNOWN IMPORTED GLOBAL)
+    message(STATUS "Using grpc: " ${GRPC2_LIBRARY})
+    set_target_properties(grpc PROPERTIES IMPORTED_LOCATION ${GRPC2_LIBRARY})
+
+    find_library(ABSL_SYNCHRONIZATION_LIBRARY absl_synchronization $GRPC_OPTS QUIET)
+    if (ABSL_SYNCHRONIZATION_LIBRARY)
+      add_library(absl_synchronization UNKNOWN IMPORTED GLOBAL)
+      message(STATUS "Using absl_synchronization: " ${ABSL_SYNCHRONIZATION_LIBRARY})
+      set_target_properties(absl_synchronization PROPERTIES IMPORTED_LOCATION ${ABSL_SYNCHRONIZATION_LIBRARY})
+    endif()
+
     if (ENABLE_GRPC_REFLECTION)
       find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection ${GRPC_OPTS} REQUIRED)
       add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
Index: clang/cmake/modules/AddGRPC.cmake
===================================================================
--- clang/cmake/modules/AddGRPC.cmake
+++ clang/cmake/modules/AddGRPC.cmake
@@ -4,8 +4,13 @@
   # Take the first two args and forward the remaining to generate_proto_sources.
   cmake_parse_arguments(PARSE_ARGV 2 PROTO "" "" "")
   generate_proto_sources(ProtoSource ${ProtoFile} ${PROTO_UNPARSED_ARGUMENTS})
+  set(LINKED_GRPC_LIBRARIES protobuf gpr grpc grpc++)
 
+  if (ABSL_SYNCHRONIZATION_LIBRARY)
+    list(APPEND LINKED_GRPC_LIBRARIES absl_synchronization)
+  endif()
   add_clang_library(${LibraryName} ${ProtoSource}
     PARTIAL_SOURCES_INTENDED
-    LINK_LIBS PUBLIC grpc++ protobuf)
+    LINK_LIBS PUBLIC  ${LINKED_GRPC_LIBRARIES})
+
 endfunction()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141047.486541.patch
Type: text/x-patch
Size: 2376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230105/4273a4a7/attachment-0001.bin>


More information about the cfe-commits mailing list