[PATCH] D84928: [clangd] Fix remote index build on macOS

Kirill Bobyrev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 03:18:38 PDT 2020


kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: llvm-commits, usaxena95, kadircet, arphaman, jkorous, mgorny.
Herald added a project: LLVM.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

macOS builds suddenly started failing:

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

After some experimentation it turns out that link_directories is not actually
adding directories to linker search path which looks like CMake bug (submitted
https://gitlab.kitware.com/cmake/cmake/-/issues/21040).

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84928

Files:
  llvm/cmake/modules/FindGRPC.cmake


Index: llvm/cmake/modules/FindGRPC.cmake
===================================================================
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -45,11 +45,25 @@
       # 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()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84928.281860.patch
Type: text/x-patch
Size: 1345 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200730/e78c2601/attachment.bin>


More information about the llvm-commits mailing list