Skip to content

Commit

Permalink
Add options to use system abseil, lz4 and cityhash
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
DavidWoorton authored and DavidKeller committed Apr 13, 2022
1 parent 91c4704 commit 16ef205
Show file tree
Hide file tree
Showing 37 changed files with 88 additions and 40 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [clang-6, gcc-7, gcc-8, gcc-9]
ssl: [ssl_ON, ssl_OFF]
compiler: []
ssl: []
dependencies: []
include:
- compiler: clang-6
INSTALL: clang-6.0
Expand All @@ -39,16 +40,23 @@ jobs:

- ssl: ssl_ON
INSTALL_SSL: libssl-dev
EXTRA_CMAKE_FLAGS: -DWITH_OPENSSL=ON
OPENSSL_CMAKE_OPTION: -DWITH_OPENSSL=ON

- ssl: ssl_OFF
EXTRA_CMAKE_FLAGS: -DWITH_OPENSSL=OFF
OPENSSL_CMAKE_OPTION: -DWITH_OPENSSL=OFF

- dependencies: dependencies_SYSTEM
DEPENDENCIES_CMAKE_OPTIONS: -DWITH_SYSTEM_ABSEIL=ON -DWITH_SYSTEM_LZ4=ON -DWITH_SYSTEM_CITYHASH=ON
INSTALL_DEPENDENCIES: libabsl-dev liblz4-dev libcityhash-dev

- dependencies: dependencies_BUILT_IN
DEPENDENCIES_CMAKE_OPTIONS: -DWITH_SYSTEM_ABSEIL=OFF -DWITH_SYSTEM_LZ4=OFF -DWITH_SYSTEM_CITYHASH=OFF

steps:
- uses: actions/checkout@v2

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

- name: Configure CMake
run: |
Expand All @@ -57,7 +65,8 @@ jobs:
-DCMAKE_CXX_COMPILER=${{ matrix.CXX_COMPILER}} \
-B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON \
${{ matrix.EXTRA_CMAKE_FLAGS }}
${{ matrix.OPENSSL_CMAKE_OPTION}} \
${{ matrix.DEPENDENCIES_CMAKE_OPTIONS }}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all
Expand Down
25 changes: 19 additions & 6 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,36 @@ jobs:
fail-fast: false
matrix:
build: [nossl, ssl]
dependencies: []
include:
- build: nossl
extra_cmake_flags: -DWITH_OPENSSL=OFF
extra_install:
openssl_cmake_option: -DWITH_OPENSSL=OFF

- build: ssl
extra_cmake_flags: -DWITH_OPENSSL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/
extra_install: openssl
openssl_cmake_option: -DWITH_OPENSSL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/
openssl_install: openssl

- dependencies: dependencies_SYSTEM
dependencies_cmake_options: -DWITH_SYSTEM_ABSEIL=ON -DWITH_SYSTEM_LZ4=ON -DWITH_SYSTEM_CITYHASH=ON
dependencies_install: abseil lz4 cityhash

- dependencies: dependencies_BUILT_IN
dependencies_cmake_options: -DWITH_SYSTEM_ABSEIL=OFF -DWITH_SYSTEM_LZ4=OFF -DWITH_SYSTEM_CITYHASH=OFF


steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: brew install cmake ${{matrix.extra_install}}
run: brew install cmake ${{matrix.openssl_install}} ${{matrix.dependencies_install}

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON ${{matrix.extra_cmake_flags}}
run: cmake \
-B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DBUILD_TESTS=ON \
${{matrix.openssl_cmake_option}} \
${{matrix.dependencies_cmake_options}}

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all
Expand Down
28 changes: 24 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ INCLUDE (cmake/openssl.cmake)
OPTION (BUILD_BENCHMARK "Build benchmark" OFF)
OPTION (BUILD_TESTS "Build tests" OFF)
OPTION (WITH_OPENSSL "Use OpenSSL for TLS connections" OFF)
OPTION (USE_SYSTEM_ABSEIL "Use system ABSEIL" OFF)
OPTION (USE_SYSTEM_LZ4 "Use system LZ4" OFF)
OPTION (USE_SYSTEM_CITYHASH "Use system cityhash" OFF)

PROJECT (CLICKHOUSE-CLIENT)

Expand All @@ -27,13 +30,30 @@ PROJECT (CLICKHOUSE-CLIENT)
ENDIF ()

INCLUDE_DIRECTORIES (.)
INCLUDE_DIRECTORIES (contrib)

IF (USE_SYSTEM_ABSEIL)
FIND_PACKAGE(absl REQUIRED)
ELSE ()
INCLUDE_DIRECTORIES (contrib/absl)
SUBDIRS (contrib/absl/absl)
ENDIF ()

IF (USE_SYSTEM_LZ4)
FIND_PACKAGE(lz4 REQUIRED)
ELSE ()
INCLUDE_DIRECTORIES (contrib/lz4/lz4)
SUBDIRS (contrib/lz4/lz4)
ENDIF ()

IF (USE_SYSTEM_CITYHASH)
FIND_PACKAGE(cityhash REQUIRED)
ELSE ()
INCLUDE_DIRECTORIES (contrib/cityhash/cityhash)
SUBDIRS (contrib/cityhash/cityhash)
ENDIF ()

SUBDIRS (
clickhouse
contrib/absl
contrib/cityhash
contrib/lz4
)

IF (BUILD_BENCHMARK)
Expand Down
12 changes: 6 additions & 6 deletions clickhouse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ ENDIF ()
ADD_LIBRARY (clickhouse-cpp-lib SHARED ${clickhouse-cpp-lib-src})
SET_TARGET_PROPERTIES(clickhouse-cpp-lib PROPERTIES LINKER_LANGUAGE CXX)
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib
absl-lib
cityhash-lib
lz4-lib
absl::absl
cityhash::cityhash
lz4::lz4
)

ADD_LIBRARY (clickhouse-cpp-lib-static STATIC ${clickhouse-cpp-lib-src})
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static
absl-lib
cityhash-lib
lz4-lib
absl::absl
cityhash::cityhash
lz4::lz4
)

IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
Expand Down
4 changes: 2 additions & 2 deletions clickhouse/base/compressed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "output.h"
#include "../exceptions.h"

#include <cityhash/city.h>
#include <lz4/lz4.h>
#include <city.h>
#include <lz4.h>
#include <stdexcept>
#include <system_error>

Expand Down
2 changes: 1 addition & 1 deletion clickhouse/columns/lowcardinality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "nullable.h"
#include "../base/wire_format.h"

#include <cityhash/city.h>
#include <city.h>

#include <functional>
#include <string_view>
Expand Down
2 changes: 1 addition & 1 deletion clickhouse/types/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "../exceptions.h"

#include <cityhash/city.h>
#include <city.h>

#include <stdexcept>

Expand Down
3 changes: 0 additions & 3 deletions contrib/absl/CMakeLists.txt

This file was deleted.

5 changes: 5 additions & 0 deletions contrib/absl/absl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ADD_LIBRARY (absl STATIC
numeric/int128.cc
)

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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions contrib/cityhash/CMakeLists.txt

This file was deleted.

File renamed without changes.
7 changes: 7 additions & 0 deletions contrib/cityhash/cityhash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ADD_LIBRARY (cityhash STATIC
city.cc
)

set_property(TARGET cityhash PROPERTY POSITION_INDEPENDENT_CODE ON)

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.
6 changes: 0 additions & 6 deletions contrib/lz4/CMakeLists.txt

This file was deleted.

File renamed without changes.
8 changes: 8 additions & 0 deletions contrib/lz4/lz4/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ADD_LIBRARY (lz4 STATIC
lz4.c
lz4hc.c
)

set_property(TARGET lz4 PROPERTY POSITION_INDEPENDENT_CODE ON)

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 comments on commit 16ef205

Please sign in to comment.