Skip to content

Commit 7fe1e84

Browse files
committed
Rely on conan to build the project on various OSes
Signed-off-by: David Keller <[email protected]>
1 parent bceea9b commit 7fe1e84

File tree

8 files changed

+219
-92
lines changed

8 files changed

+219
-92
lines changed

.github/workflows/linux.yml

+61-27
Original file line numberDiff line numberDiff line change
@@ -9,67 +9,101 @@ on:
99
env:
1010
BUILD_TYPE: Release
1111
CH_SERVER_VERSION: 21.3.17.2
12+
CONAN_USER_HOME: "${{ github.workspace }}/conan/"
1213
jobs:
1314
build:
1415
runs-on: ubuntu-latest
16+
1517
strategy:
18+
fail-fast: false
1619
matrix:
17-
compiler: [clang-6, gcc-7, gcc-8, gcc-9]
20+
compiler: [clang-6, clang-10-libc++, gcc-7, gcc-8, gcc-9]
1821
ssl: [ssl_ON, ssl_OFF]
1922
dependencies: [dependencies_SYSTEM, dependencies_BUILT_IN]
2023
include:
2124
- compiler: clang-6
2225
INSTALL: clang-6.0
23-
C_COMPILER: clang-6.0
24-
CXX_COMPILER: clang++-6.0
26+
COMPILER_CONAN_SETTING: >-
27+
-s compiler=clang
28+
-s compiler.version=6.0
29+
-s compiler.libcxx=libstdc++11
30+
-e CC=clang-6.0 -e CXX=clang++-6.0
31+
32+
- compiler: clang-10-libc++
33+
INSTALL: clang-10 libc++-dev
34+
COMPILER_CONAN_SETTING: >-
35+
-s compiler=clang
36+
-s compiler.version=10
37+
-s compiler.libcxx=libc++
38+
-e CC=clang-10 -e CXX=clang++-10
2539
2640
- compiler: gcc-7
2741
INSTALL: gcc-7 g++-7
28-
C_COMPILER: gcc-7
29-
CXX_COMPILER: g++-7
42+
COMPILER_CONAN_SETTING: >-
43+
-s compiler=gcc
44+
-s compiler.version=7
45+
-s compiler.libcxx=libstdc++11
3046
3147
- compiler: gcc-8
3248
INSTALL: gcc-8 g++-8
33-
C_COMPILER: gcc-8
34-
CXX_COMPILER: g++-8
49+
COMPILER_CONAN_SETTING: >-
50+
-s compiler=gcc
51+
-s compiler.version=8
52+
-s compiler.libcxx=libstdc++11
3553
3654
- compiler: gcc-9
3755
INSTALL: gcc-9 g++-9
38-
C_COMPILER: gcc-9
39-
CXX_COMPILER: g++-9
56+
COMPILER_CONAN_SETTING: >-
57+
-s compiler=gcc
58+
-s compiler.version=9
59+
-s compiler.libcxx=libstdc++11
4060
4161
- ssl: ssl_ON
42-
INSTALL_SSL: libssl-dev
43-
OPENSSL_CMAKE_OPTION: -DWITH_OPENSSL=ON
62+
SSL_CONAN_OPTION: -o with_openssl=True
4463

4564
- ssl: ssl_OFF
46-
OPENSSL_CMAKE_OPTION: -DWITH_OPENSSL=OFF
65+
SSL_CONAN_OPTION: -o with_openssl=False
4766

4867
- 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
68+
DEPENDENCIES_CONAN_OPTIONS: >-
69+
-o with_system_lz4=True
70+
-o with_system_cityhash=True
71+
-o with_system_abseil=True
5172
5273
- dependencies: dependencies_BUILT_IN
53-
DEPENDENCIES_CMAKE_OPTIONS: -DWITH_SYSTEM_ABSEIL=OFF -DWITH_SYSTEM_LZ4=OFF -DWITH_SYSTEM_CITYHASH=OFF
74+
DEPENDENCIES_CONAN_OPTIONS: >-
75+
-o with_system_lz4=False
76+
-o with_system_cityhash=False
77+
-o with_system_abseil=False
5478
5579
steps:
5680
- uses: actions/checkout@v2
5781

82+
- uses: turtlebrowser/get-conan@main
83+
84+
- uses: actions/[email protected]
85+
with:
86+
key: ${{runner.os}}-${{matrix.ssl}}-${{matrix.dependencies}}-${{hashFiles('conanfile.py')}}
87+
path: ${{env.CONAN_USER_HOME}}
88+
5889
- name: Install dependencies
59-
run: sudo apt-get install -y cmake ${{ matrix.INSTALL }} ${{ matrix.INSTALL_SSL }} ${{ matrix.INSTALL_DEPENDENCIES }}
90+
run: |
91+
sudo apt-get install -y cmake ${{matrix.INSTALL}}
6092
61-
- name: Configure CMake
93+
- name: Configure & Build project
6294
run: |
63-
cmake \
64-
-DCMAKE_C_COMPILER=${{ matrix.C_COMPILER}} \
65-
-DCMAKE_CXX_COMPILER=${{ matrix.CXX_COMPILER}} \
66-
-B ${{github.workspace}}/build \
67-
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON \
68-
${{ matrix.OPENSSL_CMAKE_OPTION}} \
69-
${{ matrix.DEPENDENCIES_CMAKE_OPTIONS }}
70-
71-
- name: Build
72-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all
95+
mkdir -p ${{github.workspace}}/build && cd ${{github.workspace}}/build
96+
97+
conan install \
98+
-o build_tests=True \
99+
${{matrix.SSL_CONAN_OPTION}} \
100+
${{matrix.DEPENDENCIES_CONAN_OPTIONS}} \
101+
-s build_type=${{env.BUILD_TYPE}} \
102+
${{matrix.COMPILER_CONAN_SETTING}} \
103+
-b missing \
104+
${{github.workspace}}
105+
106+
conan build ${{github.workspace}}
73107
74108
- name: Start ClickHouse server
75109
run: |

.github/workflows/macos.yml

+35-21
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,62 @@ env:
1010
BUILD_TYPE: Release
1111
CLICKHOUSE_USER: clickhouse_cpp_cicd
1212
CLICKHOUSE_PASSWORD: clickhouse_cpp_cicd
13-
13+
CONAN_USER_HOME: "${{ github.workspace }}/conan/"
1414
jobs:
1515
build:
1616
runs-on: macos-latest
1717

1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
build: [nossl, ssl]
21+
ssl: [ssl_ON, ssl_OFF]
2222
dependencies: [dependencies_SYSTEM, dependencies_BUILT_IN]
2323
include:
24-
- build: nossl
25-
openssl_cmake_option: -DWITH_OPENSSL=OFF
24+
- ssl: ssl_ON
25+
SSL_CONAN_OPTION: -o with_openssl=True
2626

27-
- build: ssl
28-
openssl_cmake_option: -DWITH_OPENSSL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/
29-
openssl_install: openssl
27+
- ssl: ssl_OFF
28+
SSL_CONAN_OPTION: -o with_openssl=False
3029

3130
- 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
31+
DEPENDENCIES_CONAN_OPTIONS: >-
32+
-o with_system_lz4=True
33+
-o with_system_cityhash=True
34+
-o with_system_abseil=True
3435
3536
- dependencies: dependencies_BUILT_IN
36-
dependencies_cmake_options: -DWITH_SYSTEM_ABSEIL=OFF -DWITH_SYSTEM_LZ4=OFF -DWITH_SYSTEM_CITYHASH=OFF
37-
37+
DEPENDENCIES_CONAN_OPTIONS: >-
38+
-o with_system_lz4=False
39+
-o with_system_cityhash=False
40+
-o with_system_abseil=False
3841
3942
steps:
4043
- uses: actions/checkout@v2
4144

45+
- uses: turtlebrowser/get-conan@main
46+
47+
- uses: actions/[email protected]
48+
with:
49+
key: ${{runner.os}}-${{matrix.ssl}}-${{matrix.dependencies}}-${{hashFiles('conanfile.py')}}
50+
path: ${{env.CONAN_USER_HOME}}
51+
4252
- name: Install dependencies
43-
run: brew install cmake ${{matrix.openssl_install}} ${{matrix.dependencies_install}}
53+
run: |
54+
brew install cmake
55+
56+
- name: Configure & Build project
57+
run: |
58+
mkdir -p ${{github.workspace}}/build && cd ${{github.workspace}}/build
4459
45-
- name: Configure CMake
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}}
60+
conan install \
61+
-o build_tests=True \
62+
${{matrix.SSL_CONAN_OPTION}} \
63+
${{matrix.DEPENDENCIES_CONAN_OPTIONS}} \
64+
-s build_type=${{env.BUILD_TYPE}} \
65+
-b missing \
66+
${{github.workspace}}
5267
53-
- name: Build
54-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all
68+
conan build ${{github.workspace}}
5569
5670
- name: Start tls offoader proxy
5771
# that mimics non-secure clickhouse running on localhost

.github/workflows/windows_msvc.yml

+16-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
branches: [ master ]
88

99
env:
10+
CONAN_USE_ALWAYS_SHORT_PATHS: True
11+
CONAN_USER_HOME_SHORT: "${{ github.workspace }}/conan"
12+
1013
BUILD_TYPE: Release
1114
GTEST_FILTER: --gtest_filter=-"*"
1215
CLICKHOUSE_USER: clickhouse_cpp_cicd
@@ -38,11 +41,20 @@ jobs:
3841
- uses: actions/checkout@v2
3942
- uses: ilammy/msvc-dev-cmd@v1
4043

41-
- name: Configure CMake
42-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON
44+
- uses: turtlebrowser/get-conan@main
45+
46+
- uses: actions/[email protected]
47+
with:
48+
key: ${{runner.os}}-${{hashFiles('conanfile.py')}}
49+
path: ${{env.CONAN_USER_HOME_SHORT}}
50+
51+
- name: Configure & Build project
52+
run: |
53+
mkdir -p ${{github.workspace}}/build && cd ${{github.workspace}}/build
54+
55+
conan install -o build_tests=True -s build_type=${{env.BUILD_TYPE}} -b missing ${{github.workspace}}
4356
44-
- name: Build
45-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
57+
conan build ${{github.workspace}}
4658
4759
- name: Start tls offoader proxy
4860
shell: bash

CMakeLists.txt

+29-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +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)
10+
OPTION (WITH_SYSTEM_ABSEIL "Use system ABSEIL" OFF)
11+
OPTION (WITH_SYSTEM_LZ4 "Use system LZ4" OFF)
12+
OPTION (WITH_SYSTEM_CITYHASH "Use system cityhash" OFF)
1313

1414
PROJECT (CLICKHOUSE-CLIENT)
1515

@@ -29,23 +29,46 @@ PROJECT (CLICKHOUSE-CLIENT)
2929
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
3030
ENDIF ()
3131

32+
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
33+
INCLUDE (CheckCXXSourceCompiles)
34+
35+
CHECK_CXX_SOURCE_COMPILES("#include <bits/c++config.h>\nint main() { return __GLIBCXX__ != 0; }"
36+
CLANG_WITH_LIB_STDCXX)
37+
ENDIF ()
38+
39+
IF (CLANG_WITH_LIB_STDCXX)
40+
# there is a problem with __builtin_mul_overflow call at link time
41+
# the error looks like: ... undefined reference to `__muloti4' ...
42+
# caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404
43+
# explicit linking to compiler-rt allows to workaround the problem
44+
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --rtlib=compiler-rt")
45+
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --rtlib=compiler-rt")
46+
47+
# some workaround for linking issues on linux:
48+
# /usr/bin/ld: CMakeFiles/simple-test.dir/main.cpp.o: undefined reference to symbol '_Unwind_Resume@@GCC_3.0'
49+
# /usr/bin/ld: /lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line
50+
# FIXME: that workaround breaks clang build on mingw
51+
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lgcc_s")
52+
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcc_s")
53+
ENDIF ()
54+
3255
INCLUDE_DIRECTORIES (.)
3356

34-
IF (USE_SYSTEM_ABSEIL)
57+
IF (WITH_SYSTEM_ABSEIL)
3558
FIND_PACKAGE(absl REQUIRED)
3659
ELSE ()
3760
INCLUDE_DIRECTORIES (contrib/absl)
3861
SUBDIRS (contrib/absl/absl)
3962
ENDIF ()
4063

41-
IF (USE_SYSTEM_LZ4)
64+
IF (WITH_SYSTEM_LZ4)
4265
FIND_PACKAGE(lz4 REQUIRED)
4366
ELSE ()
4467
INCLUDE_DIRECTORIES (contrib/lz4/lz4)
4568
SUBDIRS (contrib/lz4/lz4)
4669
ENDIF ()
4770

48-
IF (USE_SYSTEM_CITYHASH)
71+
IF (WITH_SYSTEM_CITYHASH)
4972
FIND_PACKAGE(cityhash REQUIRED)
5073
ELSE ()
5174
INCLUDE_DIRECTORIES (contrib/cityhash/cityhash)

clickhouse/CMakeLists.txt

-23
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,11 @@ TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static
5050
lz4::lz4
5151
)
5252

53-
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
54-
INCLUDE (CheckCXXSourceCompiles)
55-
56-
CHECK_CXX_SOURCE_COMPILES("#include <bits/c++config.h>\nint main() { return __GLIBCXX__ != 0; }"
57-
BUILDING_WITH_LIB_STDCXX)
58-
59-
IF (BUILDING_WITH_LIB_STDCXX)
60-
# there is a problem with __builtin_mul_overflow call at link time
61-
# the error looks like: ... undefined reference to `__muloti4' ...
62-
# caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404
63-
# explicit linking to compiler-rt allows to workaround the problem
64-
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --rtlib=compiler-rt")
65-
66-
# some workaround for linking issues on linux:
67-
# /usr/bin/ld: CMakeFiles/simple-test.dir/main.cpp.o: undefined reference to symbol '_Unwind_Resume@@GCC_3.0'
68-
# /usr/bin/ld: /lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line
69-
# FIXME: that workaround breaks clang build on mingw
70-
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib gcc_s)
71-
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static gcc_s)
72-
ENDIF ()
73-
ENDIF ()
74-
7553
INSTALL (TARGETS clickhouse-cpp-lib clickhouse-cpp-lib-static
7654
ARCHIVE DESTINATION lib
7755
LIBRARY DESTINATION lib
7856
)
7957

80-
8158
# general
8259
INSTALL(FILES block.h DESTINATION include/clickhouse/)
8360
INSTALL(FILES client.h DESTINATION include/clickhouse/)

0 commit comments

Comments
 (0)