1
1
class ClickhouseCpp < Formula
2
2
desc "C++ client library for ClickHouse"
3
3
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 "
6
6
license "Apache-2.0"
7
7
head "https://github.com/ClickHouse/clickhouse-cpp.git" , branch : "master"
8
8
@@ -17,18 +17,30 @@ class ClickhouseCpp < Formula
17
17
sha256 cellar : :any_skip_relocation , x86_64_linux : "59b4a9754fd3934831f20c2efe2398c4a56b4e7fb0de43aff7a50642e80b4bf6"
18
18
end
19
19
20
- depends_on "cmake" => [ :build , :test ]
20
+ depends_on "cmake" => :build
21
21
depends_on "abseil"
22
+ depends_on "cityhash"
23
+ depends_on "lz4"
22
24
depends_on "openssl@3"
23
25
24
26
fails_with gcc : "5"
25
27
fails_with gcc : "6"
26
28
27
29
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
32
44
system "cmake" , "--build" , "build"
33
45
system "cmake" , "--install" , "build"
34
46
end
@@ -73,24 +85,19 @@ def install
73
85
}
74
86
EOS
75
87
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 )
95
102
end
96
103
end
0 commit comments