2022-01-17 07:36:58 +00:00
|
|
|
# disable grpc due to conflicts of abseil (required by grpc) dynamic annotations with libtsan.a
|
|
|
|
if (SANITIZE STREQUAL "thread" AND COMPILER_GCC)
|
|
|
|
set(ENABLE_GRPC_DEFAULT OFF)
|
|
|
|
else()
|
|
|
|
set(ENABLE_GRPC_DEFAULT ${ENABLE_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
option(ENABLE_GRPC "Use gRPC" ${ENABLE_GRPC_DEFAULT})
|
|
|
|
|
|
|
|
if(NOT ENABLE_GRPC)
|
|
|
|
message(STATUS "Not using gRPC")
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2020-09-30 22:28:23 +00:00
|
|
|
set(_gRPC_SOURCE_DIR "${ClickHouse_SOURCE_DIR}/contrib/grpc")
|
|
|
|
set(_gRPC_BINARY_DIR "${ClickHouse_BINARY_DIR}/contrib/grpc")
|
2019-12-27 13:33:42 +00:00
|
|
|
|
2020-10-07 21:42:27 +00:00
|
|
|
# Use re2 from ClickHouse contrib, not from gRPC third_party.
|
2020-09-30 22:28:23 +00:00
|
|
|
set(gRPC_RE2_PROVIDER "clickhouse" CACHE STRING "" FORCE)
|
2022-01-17 18:45:54 +00:00
|
|
|
set(_gRPC_RE2_INCLUDE_DIR "")
|
|
|
|
set(_gRPC_RE2_LIBRARIES ch_contrib::re2)
|
2019-12-27 13:33:42 +00:00
|
|
|
|
2020-10-07 21:42:27 +00:00
|
|
|
# Use zlib from ClickHouse contrib, not from gRPC third_party.
|
2020-09-30 22:28:23 +00:00
|
|
|
set(gRPC_ZLIB_PROVIDER "clickhouse" CACHE STRING "" FORCE)
|
2022-01-16 10:34:54 +00:00
|
|
|
set(_gRPC_ZLIB_INCLUDE_DIR "")
|
|
|
|
set(_gRPC_ZLIB_LIBRARIES ch_contrib::zlib)
|
2020-09-30 22:28:23 +00:00
|
|
|
|
2020-10-07 21:42:27 +00:00
|
|
|
# Use protobuf from ClickHouse contrib, not from gRPC third_party.
|
2020-09-30 22:28:23 +00:00
|
|
|
set(gRPC_PROTOBUF_PROVIDER "clickhouse" CACHE STRING "" FORCE)
|
2022-01-17 07:46:31 +00:00
|
|
|
set(_gRPC_PROTOBUF_LIBRARIES ch_contrib::protobuf)
|
2020-09-30 22:28:23 +00:00
|
|
|
set(_gRPC_PROTOBUF_PROTOC "protoc")
|
2022-01-17 07:46:31 +00:00
|
|
|
set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protoc>)
|
|
|
|
set(_gRPC_PROTOBUF_PROTOC_LIBRARIES ch_contrib::protoc)
|
2020-09-30 22:28:23 +00:00
|
|
|
|
2022-01-17 07:36:58 +00:00
|
|
|
if(TARGET OpenSSL::SSL)
|
|
|
|
set(gRPC_USE_UNSECURE_LIBRARIES FALSE)
|
|
|
|
else()
|
|
|
|
set(gRPC_USE_UNSECURE_LIBRARIES TRUE)
|
|
|
|
endif()
|
|
|
|
|
2020-10-07 21:42:27 +00:00
|
|
|
# Use OpenSSL from ClickHouse contrib, not from gRPC third_party.
|
2020-09-30 22:28:23 +00:00
|
|
|
set(gRPC_SSL_PROVIDER "clickhouse" CACHE STRING "" FORCE)
|
2022-01-17 05:45:10 +00:00
|
|
|
set(_gRPC_SSL_INCLUDE_DIR "")
|
|
|
|
set(_gRPC_SSL_LIBRARIES OpenSSL::Crypto OpenSSL::SSL)
|
2020-05-22 20:45:13 +00:00
|
|
|
|
2020-11-16 09:45:59 +00:00
|
|
|
# Use abseil-cpp from ClickHouse contrib, not from gRPC third_party.
|
2020-10-07 21:42:27 +00:00
|
|
|
set(gRPC_ABSL_PROVIDER "clickhouse" CACHE STRING "" FORCE)
|
|
|
|
|
|
|
|
# Choose to build static or shared library for c-ares.
|
2022-01-24 11:32:17 +00:00
|
|
|
if (USE_STATIC_LIBRARIES)
|
2020-10-07 21:42:27 +00:00
|
|
|
set(CARES_STATIC ON CACHE BOOL "" FORCE)
|
|
|
|
set(CARES_SHARED OFF CACHE BOOL "" FORCE)
|
|
|
|
else ()
|
|
|
|
set(CARES_STATIC OFF CACHE BOOL "" FORCE)
|
|
|
|
set(CARES_SHARED ON CACHE BOOL "" FORCE)
|
|
|
|
endif ()
|
|
|
|
|
2020-12-22 19:07:07 +00:00
|
|
|
# Disable looking for libnsl on a platforms that has gethostbyname in glibc
|
|
|
|
#
|
|
|
|
# c-ares searching for gethostbyname in the libnsl library, however in the
|
|
|
|
# version that shipped with gRPC it doing it wrong [1], since it uses
|
|
|
|
# CHECK_LIBRARY_EXISTS(), which will return TRUE even if the function exists in
|
|
|
|
# another dependent library. The upstream already contains correct macro [2],
|
|
|
|
# but it is not included in gRPC (even upstream gRPC, not the one that is
|
|
|
|
# shipped with clickhousee).
|
|
|
|
#
|
|
|
|
# [1]: https://github.com/c-ares/c-ares/blob/e982924acee7f7313b4baa4ee5ec000c5e373c30/CMakeLists.txt#L125
|
|
|
|
# [2]: https://github.com/c-ares/c-ares/blob/44fbc813685a1fa8aa3f27fcd7544faf612d376a/CMakeLists.txt#L146
|
|
|
|
#
|
|
|
|
# And because if you by some reason have libnsl [3] installed, clickhouse will
|
|
|
|
# reject to start w/o it. While this is completelly different library.
|
|
|
|
#
|
|
|
|
# [3]: https://packages.debian.org/bullseye/libnsl2
|
|
|
|
if (NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
|
|
|
set(HAVE_LIBNSL OFF CACHE BOOL "" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2020-09-30 22:28:23 +00:00
|
|
|
# We don't want to build C# extensions.
|
|
|
|
set(gRPC_BUILD_CSHARP_EXT OFF)
|
2019-12-27 13:33:42 +00:00
|
|
|
|
2020-09-30 22:28:23 +00:00
|
|
|
add_subdirectory("${_gRPC_SOURCE_DIR}" "${_gRPC_BINARY_DIR}")
|
2019-12-27 13:33:42 +00:00
|
|
|
|
2020-09-30 22:28:23 +00:00
|
|
|
# The contrib/grpc/CMakeLists.txt redefined the PROTOBUF_GENERATE_GRPC_CPP() function for its own purposes,
|
|
|
|
# so we need to redefine it back.
|
|
|
|
include("${ClickHouse_SOURCE_DIR}/contrib/grpc-cmake/protobuf_generate_grpc.cmake")
|
2022-01-17 07:36:58 +00:00
|
|
|
|
|
|
|
set(gRPC_CPP_PLUGIN $<TARGET_FILE:grpc_cpp_plugin>)
|
|
|
|
set(gRPC_PYTHON_PLUGIN $<TARGET_FILE:grpc_python_plugin>)
|
|
|
|
|
|
|
|
set(gRPC_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/grpc/include")
|
|
|
|
if(gRPC_USE_UNSECURE_LIBRARIES)
|
|
|
|
set(gRPC_LIBRARIES grpc_unsecure grpc++_unsecure)
|
|
|
|
else()
|
|
|
|
set(gRPC_LIBRARIES grpc grpc++)
|
|
|
|
endif()
|
|
|
|
add_library(_ch_contrib_grpc INTERFACE)
|
|
|
|
target_link_libraries(_ch_contrib_grpc INTERFACE ${gRPC_LIBRARIES})
|
|
|
|
target_include_directories(_ch_contrib_grpc SYSTEM INTERFACE ${gRPC_INCLUDE_DIRS})
|
|
|
|
add_library(ch_contrib::grpc ALIAS _ch_contrib_grpc)
|