Author: Sam McCall
Date: 2020-11-26T23:08:27+01:00
New Revision: f095ac11a9550530a4a54298debb8b04b36422be

URL: 
https://github.com/llvm/llvm-project/commit/f095ac11a9550530a4a54298debb8b04b36422be
DIFF: 
https://github.com/llvm/llvm-project/commit/f095ac11a9550530a4a54298debb8b04b36422be.diff

LOG: [clangd] Fix use of system-installed GRPC after 
f726101b6240a6740b3c0926af759da5e7336f8a

We need a real target now, and it was only being created if grpc was
built from source or imported from homebrew.

Differential Revision: https://reviews.llvm.org/D92107

Added: 
    

Modified: 
    llvm/cmake/modules/FindGRPC.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/FindGRPC.cmake 
b/llvm/cmake/modules/FindGRPC.cmake
index 7031c5f0016a..8fdb3506dff1 100644
--- a/llvm/cmake/modules/FindGRPC.cmake
+++ b/llvm/cmake/modules/FindGRPC.cmake
@@ -40,6 +40,8 @@ else()
   endif()
   # On macOS the libraries are typically installed via Homebrew and are not on
   # the system path.
+  set(GRPC_OPTS "")
+  set(PROTOBUF_OPTS "")
   if (${APPLE})
     find_program(HOMEBREW brew)
     # If Homebrew is not found, the user might have installed libraries
@@ -57,28 +59,22 @@ else()
       # system path.
       if (GRPC_HOMEBREW_RETURN_CODE EQUAL "0")
         include_directories(${GRPC_HOMEBREW_PATH}/include)
-        find_library(GRPC_LIBRARY
-                     grpc++
-                     PATHS ${GRPC_HOMEBREW_PATH}/lib
-                     NO_DEFAULT_PATH
-                     REQUIRED)
-        add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
-        set_target_properties(grpc++ PROPERTIES
-                              IMPORTED_LOCATION ${GRPC_LIBRARY})
+        list(APPEND GRPC_OPTS PATHS ${GRPC_HOMEBREW_PATH}/lib NO_DEFAULT_PATH)
       endif()
       if (PROTOBUF_HOMEBREW_RETURN_CODE EQUAL "0")
         include_directories(${PROTOBUF_HOMEBREW_PATH}/include)
-        find_library(PROTOBUF_LIBRARY
-                     protobuf
-                     PATHS ${PROTOBUF_HOMEBREW_PATH}/lib
-                     NO_DEFAULT_PATH
-                     REQUIRED)
-        add_library(protobuf UNKNOWN IMPORTED GLOBAL)
-        set_target_properties(protobuf PROPERTIES
-                              IMPORTED_LOCATION ${PROTOBUF_LIBRARY})
+        list(APPEND PROTOBUF_OPTS PATHS ${PROTOBUF_HOMEBREW_PATH}/lib 
NO_DEFAULT_PATH)
       endif()
     endif()
   endif()
+  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})
+  find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED)
+  message(STATUS "Using protobuf: " ${PROTOBUF_LIBRARY})
+  add_library(protobuf UNKNOWN IMPORTED GLOBAL)
+  set_target_properties(protobuf PROPERTIES IMPORTED_LOCATION 
${PROTOBUF_LIBRARY})
 endif()
 
 # Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.


        
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to