Skip to content

Commit 550d1f4

Browse files
p-linnaneZhongRuoyu
authored andcommitted
clickhouse-cpp 2.4.0
* clickhouse-cpp 2.4.0 * clickhouse-cpp: fix build Also: 1. Add deps that would otherwise be vendored. 2. Eliminate CMake usage in test. Closes #128575. Co-authored-by: Ruoyu Zhong <[email protected]> Signed-off-by: Rui Chen <[email protected]> Signed-off-by: BrewTestBot <[email protected]>
1 parent 10d25bc commit 550d1f4

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

Formula/clickhouse-cpp.rb

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class ClickhouseCpp < Formula
22
desc "C++ client library for ClickHouse"
33
homepage "https://github.com/ClickHouse/clickhouse-cpp#readme"
4-
url "https://github.com/ClickHouse/clickhouse-cpp/archive/refs/tags/v2.3.0.tar.gz"
5-
sha256 "8eb8b49044247ccc57db73fdf41807a187d8a376d3469f255bab5c0eb0a64359"
4+
url "https://github.com/ClickHouse/clickhouse-cpp/archive/refs/tags/v2.4.0.tar.gz"
5+
sha256 "336a1d0b4c4d6bd67bd272afab3bdac51695f8b0e93dd6c85d4d774d6c7df8ad"
66
license "Apache-2.0"
77
head "https://github.com/ClickHouse/clickhouse-cpp.git", branch: "master"
88

@@ -17,18 +17,30 @@ class ClickhouseCpp < Formula
1717
sha256 cellar: :any_skip_relocation, x86_64_linux: "59b4a9754fd3934831f20c2efe2398c4a56b4e7fb0de43aff7a50642e80b4bf6"
1818
end
1919

20-
depends_on "cmake" => [:build, :test]
20+
depends_on "cmake" => :build
2121
depends_on "abseil"
22+
depends_on "cityhash"
23+
depends_on "lz4"
2224
depends_on "openssl@3"
2325

2426
fails_with gcc: "5"
2527
fails_with gcc: "6"
2628

2729
def install
28-
system "cmake", "-S", ".", "-B", "build",
29-
"-DWITH_OPENSSL=ON",
30-
"-DOPENSSL_ROOT_DIR=#{Formula["openssl@3"].opt_prefix}",
31-
*std_cmake_args
30+
# `cityhash` does not provide a pkg-config or CMake config file.
31+
# Help CMake find it.
32+
inreplace "CMakeLists.txt", "FIND_PACKAGE(cityhash REQUIRED)",
33+
"FIND_LIBRARY(CITYHASH NAMES cityhash REQUIRED)"
34+
inreplace "clickhouse/CMakeLists.txt", "cityhash::cityhash", "cityhash"
35+
36+
args = %W[
37+
-DWITH_OPENSSL=ON
38+
-DOPENSSL_ROOT_DIR=#{Formula["openssl@3"].opt_prefix}
39+
-DWITH_SYSTEM_ABSEIL=ON
40+
-DWITH_SYSTEM_CITYHASH=ON
41+
-DWITH_SYSTEM_LZ4=ON
42+
]
43+
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
3244
system "cmake", "--build", "build"
3345
system "cmake", "--install", "build"
3446
end
@@ -73,24 +85,19 @@ def install
7385
}
7486
EOS
7587

76-
(testpath/"CMakeLists.txt").write <<~EOS
77-
project (clickhouse-cpp-test-client LANGUAGES CXX)
78-
79-
set (CMAKE_CXX_STANDARD 17)
80-
set (CMAKE_CXX_STANDARD_REQUIRED ON)
81-
82-
set (CLICKHOUSE_CPP_INCLUDE "#{include}")
83-
find_library (CLICKHOUSE_CPP_LIB NAMES clickhouse-cpp-lib PATHS "#{lib}" REQUIRED NO_DEFAULT_PATH)
84-
85-
add_executable (test-client main.cpp)
86-
target_include_directories (test-client PRIVATE ${CLICKHOUSE_CPP_INCLUDE})
87-
target_link_libraries (test-client PRIVATE ${CLICKHOUSE_CPP_LIB})
88-
target_compile_definitions (test-client PUBLIC WITH_OPENSSL)
89-
EOS
90-
91-
system "cmake", "-S", testpath, "-B", (testpath/"build"), *std_cmake_args
92-
system "cmake", "--build", (testpath/"build")
93-
94-
assert_match "Exception: fail to connect: ", shell_output(testpath/"build"/"test-client", 1)
88+
args = %W[
89+
-std=c++17
90+
-I#{include}
91+
-L#{lib}
92+
-lclickhouse-cpp-lib
93+
-L#{Formula["openssl@3"].opt_lib}
94+
-lcrypto -lssl
95+
-L#{Formula["cityhash"].opt_lib}
96+
-lcityhash
97+
-L#{Formula["lz4"].opt_lib}
98+
-llz4
99+
]
100+
system ENV.cxx, "main.cpp", *args, "-o", "test-client"
101+
assert_match "Exception: fail to connect: ", shell_output("./test-client", 1)
95102
end
96103
end

0 commit comments

Comments
 (0)