[clangd] Fix remote index build on macOS
authorKirill Bobyrev <kbobyrev@google.com>
Fri, 31 Jul 2020 12:02:19 +0000 (14:02 +0200)
committerKirill Bobyrev <kbobyrev@google.com>
Fri, 31 Jul 2020 12:02:24 +0000 (14:02 +0200)
macOS builds suddenly started failing:

https://github.com/kirillbobyrev/indexing-tools/runs/925090879

This patch makes use of imported libraries and fixes builds for macOS.

Landing this without a review since the patch is quite straightforward
and I've been testing it on my local macOS machine for a while.

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

llvm/cmake/modules/FindGRPC.cmake

index 8a0ca59..70d67ce 100644 (file)
@@ -45,11 +45,25 @@ else()
       # system path.
       if (GRPC_HOMEBREW_RETURN_CODE EQUAL "0")
         include_directories(${GRPC_HOMEBREW_PATH}/include)
-        link_directories(${GRPC_HOMEBREW_PATH}/lib)
+        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})
       endif()
       if (PROTOBUF_HOMEBREW_RETURN_CODE EQUAL "0")
         include_directories(${PROTOBUF_HOMEBREW_PATH}/include)
-        link_directories(${PROTOBUF_HOMEBREW_PATH}/lib)
+        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})
       endif()
     endif()
   endif()