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 #86, #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 c6354b1
Show file tree
Hide file tree
Showing 36 changed files with 67 additions and 33 deletions.
18 changes: 13 additions & 5 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,10 +40,16 @@ 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

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

steps:
- uses: actions/checkout@v2
Expand All @@ -57,7 +64,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
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 c6354b1

Please sign in to comment.