diff --git a/cmake/find/grpc.cmake b/cmake/find/grpc.cmake index 216f8ae1878..52d0e042573 100644 --- a/cmake/find/grpc.cmake +++ b/cmake/find/grpc.cmake @@ -7,10 +7,17 @@ if (NOT ENABLE_GRPC) return() endif() -option (USE_INTERNAL_GRPC_LIBRARY "Set to FALSE to use system gRPC library instead of bundled" ${NOT_UNBUNDLED}) +option (USE_INTERNAL_GRPC_LIBRARY + "Set to FALSE to use system gRPC library instead of bundled. (Experimental. Set to OFF on your own risk)" + ${NOT_UNBUNDLED}) if (NOT USE_INTERNAL_GRPC_LIBRARY) find_package(grpc) + if (NOT GRPC_FOUND) + find_path(GRPC_INCLUDE_DIR grpcpp/grpcpp.h) + find_library(GRPC_LIBRARY grpc++) + endif () + if (GRPC_INCLUDE_DIR AND GRPC_LIBRARY) set (USE_GRPC ON) else() diff --git a/cmake/find/protobuf.cmake b/cmake/find/protobuf.cmake index 49d09299f27..a7769206e9f 100644 --- a/cmake/find/protobuf.cmake +++ b/cmake/find/protobuf.cmake @@ -20,15 +20,17 @@ endif() if(NOT USE_INTERNAL_PROTOBUF_LIBRARY) find_package(Protobuf) - if (NOT Protobuf_LIBRARY OR NOT Protobuf_INCLUDE_DIR) + if (Protobuf_LIBRARY AND Protobuf_INCLUDE_DIR AND Protobuf_PROTOC_EXECUTABLE) + set(EXTERNAL_PROTOBUF_LIBRARY_FOUND 1) + set(USE_PROTOBUF 1) + else() message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find system protobuf") + set(EXTERNAL_PROTOBUF_LIBRARY_FOUND 0) endif() endif() -if (Protobuf_LIBRARY AND Protobuf_INCLUDE_DIR) - set(USE_PROTOBUF 1) -elseif(NOT MISSING_INTERNAL_PROTOBUF_LIBRARY) - set(Protobuf_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/protobuf/src) +if (NOT EXTERNAL_PROTOBUF_LIBRARY_FOUND AND NOT MISSING_INTERNAL_PROTOBUF_LIBRARY) + set(Protobuf_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/protobuf/src") set(USE_PROTOBUF 1) set(USE_INTERNAL_PROTOBUF_LIBRARY 1) @@ -43,13 +45,13 @@ if(OS_FREEBSD AND SANITIZE STREQUAL "address") # ../contrib/protobuf/src/google/protobuf/arena_impl.h:45:10: fatal error: 'sanitizer/asan_interface.h' file not found # #include if(LLVM_INCLUDE_DIRS) - set(Protobuf_INCLUDE_DIR ${Protobuf_INCLUDE_DIR} ${LLVM_INCLUDE_DIRS}) + set(Protobuf_INCLUDE_DIR "${Protobuf_INCLUDE_DIR}" ${LLVM_INCLUDE_DIRS}) else() message (${RECONFIGURE_MESSAGE_LEVEL} "Can't use protobuf on FreeBSD with address sanitizer without LLVM") set(USE_PROTOBUF 0) endif() endif() -include (${ClickHouse_SOURCE_DIR}/cmake/protobuf_generate_cpp.cmake) +include ("${ClickHouse_SOURCE_DIR}/cmake/protobuf_generate_cpp.cmake") message(STATUS "Using protobuf=${USE_PROTOBUF}: ${Protobuf_INCLUDE_DIR} : ${Protobuf_LIBRARY} : ${Protobuf_PROTOC_EXECUTABLE}") diff --git a/cmake/target.cmake b/cmake/target.cmake index 35040e48956..5646d60df5e 100644 --- a/cmake/target.cmake +++ b/cmake/target.cmake @@ -19,6 +19,7 @@ if (CMAKE_CROSSCOMPILING) # FIXME: broken dependencies set (USE_SNAPPY OFF CACHE INTERNAL "") set (ENABLE_PROTOBUF OFF CACHE INTERNAL "") + set (ENABLE_GRPC OFF CACHE INTERNAL "") set (ENABLE_PARQUET OFF CACHE INTERNAL "") set (ENABLE_ICU OFF CACHE INTERNAL "") set (ENABLE_FASTOPS OFF CACHE INTERNAL "") @@ -26,12 +27,14 @@ if (CMAKE_CROSSCOMPILING) if (ARCH_AARCH64) # FIXME: broken dependencies set (ENABLE_PROTOBUF OFF CACHE INTERNAL "") + set (ENABLE_GRPC OFF CACHE INTERNAL "") set (ENABLE_PARQUET OFF CACHE INTERNAL "") set (ENABLE_MYSQL OFF CACHE INTERNAL "") endif () elseif (OS_FREEBSD) # FIXME: broken dependencies set (ENABLE_PROTOBUF OFF CACHE INTERNAL "") + set (ENABLE_GRPC OFF CACHE INTERNAL "") set (ENABLE_EMBEDDED_COMPILER OFF CACHE INTERNAL "") else () message (FATAL_ERROR "Trying to cross-compile to unsupported system: ${CMAKE_SYSTEM_NAME}!") diff --git a/contrib/protobuf-cmake/CMakeLists.txt b/contrib/protobuf-cmake/CMakeLists.txt index 3cb9053d647..683429194fc 100644 --- a/contrib/protobuf-cmake/CMakeLists.txt +++ b/contrib/protobuf-cmake/CMakeLists.txt @@ -1,5 +1,5 @@ -set(protobuf_SOURCE_DIR ${ClickHouse_SOURCE_DIR}/contrib/protobuf) -set(protobuf_BINARY_DIR ${ClickHouse_BINARY_DIR}/contrib/protobuf) +set(protobuf_SOURCE_DIR "${ClickHouse_SOURCE_DIR}/contrib/protobuf") +set(protobuf_BINARY_DIR "${ClickHouse_BINARY_DIR}/contrib/protobuf") set(protobuf_WITH_ZLIB 0 CACHE INTERNAL "" FORCE) # actually will use zlib, but skip find set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "" FORCE) @@ -10,4 +10,4 @@ else () set(protobuf_BUILD_SHARED_LIBS ON CACHE INTERNAL "" FORCE) endif () -add_subdirectory(${protobuf_SOURCE_DIR}/cmake ${protobuf_BINARY_DIR}) +add_subdirectory("${protobuf_SOURCE_DIR}/cmake" "${protobuf_BINARY_DIR}")