Skip to content

Commit b0cd98c

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 91c4704 commit b0cd98c

37 files changed

+86
-38
lines changed

.github/workflows/linux.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
matrix:
1717
compiler: [clang-6, gcc-7, gcc-8, gcc-9]
1818
ssl: [ssl_ON, ssl_OFF]
19+
dependencies: [dependencies_SYSTEM, dependencies_BUILT_IN]
1920
include:
2021
- compiler: clang-6
2122
INSTALL: clang-6.0
@@ -39,16 +40,23 @@ 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+
INSTALL_DEPENDENCIES: libabsl-dev liblz4-dev libcityhash-dev
51+
52+
- dependencies: dependencies_BUILT_IN
53+
DEPENDENCIES_CMAKE_OPTIONS: -DWITH_SYSTEM_ABSEIL=OFF -DWITH_SYSTEM_LZ4=OFF -DWITH_SYSTEM_CITYHASH=OFF
4654

4755
steps:
4856
- uses: actions/checkout@v2
4957

5058
- name: Install dependencies
51-
run: sudo apt-get install -y cmake ${{ matrix.INSTALL }} ${{ matrix.INSTALL_SSL }}
59+
run: sudo apt-get install -y cmake ${{ matrix.INSTALL }} ${{ matrix.INSTALL_SSL }} ${{ matrix.INSTALL_DEPENDENCIES }}
5260

5361
- name: Configure CMake
5462
run: |
@@ -57,7 +65,8 @@ jobs:
5765
-DCMAKE_CXX_COMPILER=${{ matrix.CXX_COMPILER}} \
5866
-B ${{github.workspace}}/build \
5967
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON \
60-
${{ matrix.EXTRA_CMAKE_FLAGS }}
68+
${{ matrix.OPENSSL_CMAKE_OPTION}} \
69+
${{ matrix.DEPENDENCIES_CMAKE_OPTIONS }}
6170
6271
- name: Build
6372
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all

.github/workflows/macos.yml

+19-6
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,36 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
build: [nossl, ssl]
22+
dependencies: [dependencies_SYSTEM, dependencies_BUILT_IN]
2223
include:
2324
- build: nossl
24-
extra_cmake_flags: -DWITH_OPENSSL=OFF
25-
extra_install:
25+
openssl_cmake_option: -DWITH_OPENSSL=OFF
2626

2727
- build: ssl
28-
extra_cmake_flags: -DWITH_OPENSSL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/
29-
extra_install: openssl
28+
openssl_cmake_option: -DWITH_OPENSSL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/
29+
openssl_install: openssl
30+
31+
- dependencies: dependencies_SYSTEM
32+
dependencies_cmake_options: -DWITH_SYSTEM_ABSEIL=ON -DWITH_SYSTEM_LZ4=ON -DWITH_SYSTEM_CITYHASH=ON
33+
dependencies_install: abseil lz4 cityhash
34+
35+
- dependencies: dependencies_BUILT_IN
36+
dependencies_cmake_options: -DWITH_SYSTEM_ABSEIL=OFF -DWITH_SYSTEM_LZ4=OFF -DWITH_SYSTEM_CITYHASH=OFF
37+
3038

3139
steps:
3240
- uses: actions/checkout@v2
3341

3442
- name: Install dependencies
35-
run: brew install cmake ${{matrix.extra_install}}
43+
run: brew install cmake ${{matrix.openssl_install}} ${{matrix.dependencies_install}}
3644

3745
- name: Configure CMake
38-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON ${{matrix.extra_cmake_flags}}
46+
run: cmake \
47+
-B ${{github.workspace}}/build \
48+
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
49+
-DBUILD_TESTS=ON \
50+
${{matrix.openssl_cmake_option}} \
51+
${{matrix.dependencies_cmake_options}}
3952

4053
- name: Build
4154
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
@@ -3,8 +3,8 @@
33
#include "output.h"
44
#include "../exceptions.h"
55

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

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
@@ -2,7 +2,7 @@
22

33
#include "../exceptions.h"
44

5-
#include <cityhash/city.h>
5+
#include <city.h>
66

77
#include <stdexcept>
88

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)