diff --git a/llvm/cmake/modules/FindGRPC.cmake b/llvm/cmake/modules/FindGRPC.cmake --- a/llvm/cmake/modules/FindGRPC.cmake +++ b/llvm/cmake/modules/FindGRPC.cmake @@ -26,6 +26,13 @@ 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") endif() + if (BUILD_SHARED_LIBS) + set(GRPC_LIB_NAME "grpc++") + set(PROTOBUF_LIB_NAME "libprotobuf") + else() + set(GRPC_LIB_NAME "libgrpc++.a") + set(PROTOBUF_LIB_NAME "libprotobuf.a") + endif() # On macOS the libraries are typically installed via Homebrew and are not on # the system path. if (${APPLE}) @@ -46,7 +53,7 @@ if (GRPC_HOMEBREW_RETURN_CODE EQUAL "0") include_directories(${GRPC_HOMEBREW_PATH}/include) find_library(GRPC_LIBRARY - grpc++ + ${GRPC_LIB_NAME} PATHS ${GRPC_HOMEBREW_PATH}/lib NO_DEFAULT_PATH REQUIRED) @@ -57,7 +64,7 @@ if (PROTOBUF_HOMEBREW_RETURN_CODE EQUAL "0") include_directories(${PROTOBUF_HOMEBREW_PATH}/include) find_library(PROTOBUF_LIBRARY - protobuf + ${PROTOBUF_LIB_NAME} PATHS ${PROTOBUF_HOMEBREW_PATH}/lib NO_DEFAULT_PATH REQUIRED) @@ -66,6 +73,19 @@ IMPORTED_LOCATION ${PROTOBUF_LIBRARY}) endif() endif() + elseif(${UNIX}) + find_library(GRPC_LIBRARY + ${GRPC_LIB_NAME} + REQUIRED) + add_library(grpc++ UNKNOWN IMPORTED GLOBAL) + set_target_properties(grpc++ PROPERTIES + IMPORTED_LOCATION ${GRPC_LIBRARY}) + find_library(PROTOBUF_LIBRARY + ${PROTOBUF_LIB_NAME} + REQUIRED) + add_library(protobuf UNKNOWN IMPORTED GLOBAL) + set_target_properties(protobuf PROPERTIES + IMPORTED_LOCATION ${PROTOBUF_LIBRARY}) endif() endif()