diff --git a/clang-tools-extra/clangd/index/remote/README.md b/clang-tools-extra/clangd/index/remote/README.md --- a/clang-tools-extra/clangd/index/remote/README.md +++ b/clang-tools-extra/clangd/index/remote/README.md @@ -11,8 +11,9 @@ ## Building -This feature uses gRPC and Protobuf libraries, so you will need to install them. -There are two ways of doing that. +This feature uses gRPC (known to work with versions starting from 1.27.0) and +Protobuf libraries, so you will need to install them. There are two ways of +doing that. However you install dependencies, to enable this feature and build remote index tools you will need to set this CMake flag — `-DCLANGD_ENABLE_REMOTE=On`. 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 @@ -6,7 +6,7 @@ set(protobuf_MODULE_COMPATIBLE TRUE) find_package(Protobuf CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH}) message(STATUS "Using protobuf ${protobuf_VERSION}") - find_package(gRPC CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH}) + find_package(gRPC 1.27 CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH}) message(STATUS "Using gRPC ${gRPC_VERSION}") include_directories(${Protobuf_INCLUDE_DIRS}) @@ -29,6 +29,7 @@ # On macOS the libraries are typically installed via Homebrew and are not on # the system path. if (${APPLE}) + # FIXME(kirillbobyrev): Check gRPC version for macOS, too. find_program(HOMEBREW brew) # If Homebrew is not found, the user might have installed libraries # manually. Fall back to the system path. @@ -52,6 +53,24 @@ link_directories(${PROTOBUF_HOMEBREW_PATH}/lib) endif() endif() + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") + # Try to figure out gRPC version using APT for Debian-like Linux + # distributions. + find_program(APT apt) + if (NOT APT-NOTFOUND) + execute_process(COMMAND ${APT} policy libgrpc++-dev + OUTPUT_VARIABLE APT_GRPC_POLICY + RESULT_VARIABLE APT_GRPC_POLICY_RETURN_CODE) + if (APT_GRPC_POLICY_RETURN_CODE EQUAL "0") + # Parse MAJOR.MINOR gRPC version. + string(REGEX MATCH "Installed: ([0-9]+\\.[0-9]+)" + gRPC_VERSION ${APT_GRPC_POLICY}) + if (CMAKE_MATCH_1 VERSION_LESS "1.27") + message(FATAL_ERROR "gRPC version rerquied: >=1.27, found: ${CMAKE_MATCH_1}") + endif() + message(STATUS "Using gRPC ${gRPC_VERSION}") + endif() + endif() endif() endif()