Skip to content

Commit 4a2fd8f

Browse files
DavidWoortonDavidKeller
authored andcommitted
Add options to use system abseil, lz4 and cityhash
This change solves ClickHouse#86, ClickHouse#99. Furthermore, it eases Conan packaging, as Conan already provides abseil, lz4 and cityhash. Signed-off-by: David Keller <[email protected]>
1 parent a85a982 commit 4a2fd8f

36 files changed

+67
-33
lines changed

.github/workflows/linux.yml

+13-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
compiler: [clang-6, gcc-7, gcc-8, gcc-9]
18-
ssl: [ssl_ON, ssl_OFF]
17+
compiler: []
18+
ssl: []
19+
dependencies: []
1920
include:
2021
- compiler: clang-6
2122
INSTALL: clang-6.0
@@ -39,10 +40,16 @@ jobs:
3940

4041
- ssl: ssl_ON
4142
INSTALL_SSL: libssl-dev
42-
EXTRA_CMAKE_FLAGS: -DWITH_OPENSSL=ON
43+
OPENSSL_CMAKE_OPTION: -DWITH_OPENSSL=ON
4344

4445
- ssl: ssl_OFF
45-
EXTRA_CMAKE_FLAGS: -DWITH_OPENSSL=OFF
46+
OPENSSL_CMAKE_OPTION: -DWITH_OPENSSL=OFF
47+
48+
- dependencies: dependencies_SYSTEM
49+
DEPENDENCIES_CMAKE_OPTIONS: -DWITH_SYSTEM_ABSEIL=ON -DWITH_SYSTEM_LZ4=ON -DWITH_SYSTEM_CITYHASH=ON
50+
51+
- dependencies: dependencies_BUILT_IN
52+
DEPENDENCIES_CMAKE_OPTIONS: -DWITH_SYSTEM_ABSEIL=OFF -DWITH_SYSTEM_LZ4=OFF -DWITH_SYSTEM_CITYHASH=OFF
4653

4754
steps:
4855
- uses: actions/checkout@v2
@@ -57,7 +64,8 @@ jobs:
5764
-DCMAKE_CXX_COMPILER=${{ matrix.CXX_COMPILER}} \
5865
-B ${{github.workspace}}/build \
5966
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON \
60-
${{ matrix.EXTRA_CMAKE_FLAGS }}
67+
${{ matrix.OPENSSL_CMAKE_OPTION}} \
68+
${{ matrix.DEPENDENCIES_CMAKE_OPTIONS }}
6169
6270
- name: Build
6371
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all

CMakeLists.txt

+24-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ INCLUDE (cmake/openssl.cmake)
77
OPTION (BUILD_BENCHMARK "Build benchmark" OFF)
88
OPTION (BUILD_TESTS "Build tests" OFF)
99
OPTION (WITH_OPENSSL "Use OpenSSL for TLS connections" OFF)
10+
OPTION (USE_SYSTEM_ABSEIL "Use system ABSEIL" OFF)
11+
OPTION (USE_SYSTEM_LZ4 "Use system LZ4" OFF)
12+
OPTION (USE_SYSTEM_CITYHASH "Use system cityhash" OFF)
1013

1114
PROJECT (CLICKHOUSE-CLIENT)
1215

@@ -27,13 +30,30 @@ PROJECT (CLICKHOUSE-CLIENT)
2730
ENDIF ()
2831

2932
INCLUDE_DIRECTORIES (.)
30-
INCLUDE_DIRECTORIES (contrib)
33+
34+
IF (USE_SYSTEM_ABSEIL)
35+
FIND_PACKAGE(absl REQUIRED)
36+
ELSE ()
37+
INCLUDE_DIRECTORIES (contrib/absl)
38+
SUBDIRS (contrib/absl/absl)
39+
ENDIF ()
40+
41+
IF (USE_SYSTEM_LZ4)
42+
FIND_PACKAGE(lz4 REQUIRED)
43+
ELSE ()
44+
INCLUDE_DIRECTORIES (contrib/lz4/lz4)
45+
SUBDIRS (contrib/lz4/lz4)
46+
ENDIF ()
47+
48+
IF (USE_SYSTEM_CITYHASH)
49+
FIND_PACKAGE(cityhash REQUIRED)
50+
ELSE ()
51+
INCLUDE_DIRECTORIES (contrib/cityhash/cityhash)
52+
SUBDIRS (contrib/cityhash/cityhash)
53+
ENDIF ()
3154

3255
SUBDIRS (
3356
clickhouse
34-
contrib/absl
35-
contrib/cityhash
36-
contrib/lz4
3757
)
3858

3959
IF (BUILD_BENCHMARK)

clickhouse/CMakeLists.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ ENDIF ()
3838
ADD_LIBRARY (clickhouse-cpp-lib SHARED ${clickhouse-cpp-lib-src})
3939
SET_TARGET_PROPERTIES(clickhouse-cpp-lib PROPERTIES LINKER_LANGUAGE CXX)
4040
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib
41-
absl-lib
42-
cityhash-lib
43-
lz4-lib
41+
absl::absl
42+
cityhash::cityhash
43+
lz4::lz4
4444
)
4545

4646
ADD_LIBRARY (clickhouse-cpp-lib-static STATIC ${clickhouse-cpp-lib-src})
4747
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static
48-
absl-lib
49-
cityhash-lib
50-
lz4-lib
48+
absl::absl
49+
cityhash::cityhash
50+
lz4::lz4
5151
)
5252

5353
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

clickhouse/base/compressed.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include "wire_format.h"
33
#include "output.h"
44

5-
#include <cityhash/city.h>
6-
#include <lz4/lz4.h>
5+
#include <city.h>
6+
#include <lz4.h>
77
#include <stdexcept>
88
#include <system_error>
99

clickhouse/columns/lowcardinality.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "nullable.h"
55
#include "../base/wire_format.h"
66

7-
#include <cityhash/city.h>
7+
#include <city.h>
88

99
#include <functional>
1010
#include <string_view>

clickhouse/types/types.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "types.h"
22

3-
#include <cityhash/city.h>
3+
#include <city.h>
44

55
#include <stdexcept>
66

contrib/absl/CMakeLists.txt

-3
This file was deleted.

contrib/absl/absl/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ADD_LIBRARY (absl STATIC
2+
numeric/int128.cc
3+
)
4+
5+
ADD_LIBRARY (absl::absl ALIAS absl)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

contrib/cityhash/CMakeLists.txt

-5
This file was deleted.
File renamed without changes.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ADD_LIBRARY (cityhash STATIC
2+
city.cc
3+
)
4+
5+
set_property(TARGET cityhash PROPERTY POSITION_INDEPENDENT_CODE ON)
6+
7+
ADD_LIBRARY (cityhash::cityhash ALIAS cityhash)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

contrib/lz4/CMakeLists.txt

-6
This file was deleted.
File renamed without changes.

contrib/lz4/lz4/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ADD_LIBRARY (lz4 STATIC
2+
lz4.c
3+
lz4hc.c
4+
)
5+
6+
set_property(TARGET lz4 PROPERTY POSITION_INDEPENDENT_CODE ON)
7+
8+
ADD_LIBRARY(lz4::lz4 ALIAS lz4)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)