Skip to content

Commit

Permalink
Rely on conan to build the project on various OSes
Browse files Browse the repository at this point in the history
Signed-off-by: David Keller <[email protected]>
  • Loading branch information
DavidWoorton committed Apr 21, 2022
1 parent bceea9b commit 7fe1e84
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 92 deletions.
88 changes: 61 additions & 27 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,67 +9,101 @@ on:
env:
BUILD_TYPE: Release
CH_SERVER_VERSION: 21.3.17.2
CONAN_USER_HOME: "${{ github.workspace }}/conan/"
jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
compiler: [clang-6, gcc-7, gcc-8, gcc-9]
compiler: [clang-6, clang-10-libc++, gcc-7, gcc-8, gcc-9]
ssl: [ssl_ON, ssl_OFF]
dependencies: [dependencies_SYSTEM, dependencies_BUILT_IN]
include:
- compiler: clang-6
INSTALL: clang-6.0
C_COMPILER: clang-6.0
CXX_COMPILER: clang++-6.0
COMPILER_CONAN_SETTING: >-
-s compiler=clang
-s compiler.version=6.0
-s compiler.libcxx=libstdc++11
-e CC=clang-6.0 -e CXX=clang++-6.0
- compiler: clang-10-libc++
INSTALL: clang-10 libc++-dev
COMPILER_CONAN_SETTING: >-
-s compiler=clang
-s compiler.version=10
-s compiler.libcxx=libc++
-e CC=clang-10 -e CXX=clang++-10
- compiler: gcc-7
INSTALL: gcc-7 g++-7
C_COMPILER: gcc-7
CXX_COMPILER: g++-7
COMPILER_CONAN_SETTING: >-
-s compiler=gcc
-s compiler.version=7
-s compiler.libcxx=libstdc++11
- compiler: gcc-8
INSTALL: gcc-8 g++-8
C_COMPILER: gcc-8
CXX_COMPILER: g++-8
COMPILER_CONAN_SETTING: >-
-s compiler=gcc
-s compiler.version=8
-s compiler.libcxx=libstdc++11
- compiler: gcc-9
INSTALL: gcc-9 g++-9
C_COMPILER: gcc-9
CXX_COMPILER: g++-9
COMPILER_CONAN_SETTING: >-
-s compiler=gcc
-s compiler.version=9
-s compiler.libcxx=libstdc++11
- ssl: ssl_ON
INSTALL_SSL: libssl-dev
OPENSSL_CMAKE_OPTION: -DWITH_OPENSSL=ON
SSL_CONAN_OPTION: -o with_openssl=True

- ssl: ssl_OFF
OPENSSL_CMAKE_OPTION: -DWITH_OPENSSL=OFF
SSL_CONAN_OPTION: -o with_openssl=False

- 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_CONAN_OPTIONS: >-
-o with_system_lz4=True
-o with_system_cityhash=True
-o with_system_abseil=True
- dependencies: dependencies_BUILT_IN
DEPENDENCIES_CMAKE_OPTIONS: -DWITH_SYSTEM_ABSEIL=OFF -DWITH_SYSTEM_LZ4=OFF -DWITH_SYSTEM_CITYHASH=OFF
DEPENDENCIES_CONAN_OPTIONS: >-
-o with_system_lz4=False
-o with_system_cityhash=False
-o with_system_abseil=False
steps:
- uses: actions/checkout@v2

- uses: turtlebrowser/get-conan@main

- uses: actions/[email protected]
with:
key: ${{runner.os}}-${{matrix.ssl}}-${{matrix.dependencies}}-${{hashFiles('conanfile.py')}}
path: ${{env.CONAN_USER_HOME}}

- name: Install dependencies
run: sudo apt-get install -y cmake ${{ matrix.INSTALL }} ${{ matrix.INSTALL_SSL }} ${{ matrix.INSTALL_DEPENDENCIES }}
run: |
sudo apt-get install -y cmake ${{matrix.INSTALL}}
- name: Configure CMake
- name: Configure & Build project
run: |
cmake \
-DCMAKE_C_COMPILER=${{ matrix.C_COMPILER}} \
-DCMAKE_CXX_COMPILER=${{ matrix.CXX_COMPILER}} \
-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
mkdir -p ${{github.workspace}}/build && cd ${{github.workspace}}/build
conan install \
-o build_tests=True \
${{matrix.SSL_CONAN_OPTION}} \
${{matrix.DEPENDENCIES_CONAN_OPTIONS}} \
-s build_type=${{env.BUILD_TYPE}} \
${{matrix.COMPILER_CONAN_SETTING}} \
-b missing \
${{github.workspace}}
conan build ${{github.workspace}}
- name: Start ClickHouse server
run: |
Expand Down
56 changes: 35 additions & 21 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,62 @@ env:
BUILD_TYPE: Release
CLICKHOUSE_USER: clickhouse_cpp_cicd
CLICKHOUSE_PASSWORD: clickhouse_cpp_cicd

CONAN_USER_HOME: "${{ github.workspace }}/conan/"
jobs:
build:
runs-on: macos-latest

strategy:
fail-fast: false
matrix:
build: [nossl, ssl]
ssl: [ssl_ON, ssl_OFF]
dependencies: [dependencies_SYSTEM, dependencies_BUILT_IN]
include:
- build: nossl
openssl_cmake_option: -DWITH_OPENSSL=OFF
- ssl: ssl_ON
SSL_CONAN_OPTION: -o with_openssl=True

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

- dependencies: dependencies_SYSTEM
dependencies_cmake_options: -DWITH_SYSTEM_ABSEIL=ON -DWITH_SYSTEM_LZ4=ON -DWITH_SYSTEM_CITYHASH=ON
dependencies_install: abseil lz4 cityhash
DEPENDENCIES_CONAN_OPTIONS: >-
-o with_system_lz4=True
-o with_system_cityhash=True
-o with_system_abseil=True
- dependencies: dependencies_BUILT_IN
dependencies_cmake_options: -DWITH_SYSTEM_ABSEIL=OFF -DWITH_SYSTEM_LZ4=OFF -DWITH_SYSTEM_CITYHASH=OFF

DEPENDENCIES_CONAN_OPTIONS: >-
-o with_system_lz4=False
-o with_system_cityhash=False
-o with_system_abseil=False
steps:
- uses: actions/checkout@v2

- uses: turtlebrowser/get-conan@main

- uses: actions/[email protected]
with:
key: ${{runner.os}}-${{matrix.ssl}}-${{matrix.dependencies}}-${{hashFiles('conanfile.py')}}
path: ${{env.CONAN_USER_HOME}}

- name: Install dependencies
run: brew install cmake ${{matrix.openssl_install}} ${{matrix.dependencies_install}}
run: |
brew install cmake
- name: Configure & Build project
run: |
mkdir -p ${{github.workspace}}/build && cd ${{github.workspace}}/build
- name: Configure CMake
run: cmake \
-B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DBUILD_TESTS=ON \
${{matrix.openssl_cmake_option}} \
${{matrix.dependencies_cmake_options}}
conan install \
-o build_tests=True \
${{matrix.SSL_CONAN_OPTION}} \
${{matrix.DEPENDENCIES_CONAN_OPTIONS}} \
-s build_type=${{env.BUILD_TYPE}} \
-b missing \
${{github.workspace}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all
conan build ${{github.workspace}}
- name: Start tls offoader proxy
# that mimics non-secure clickhouse running on localhost
Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/windows_msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches: [ master ]

env:
CONAN_USE_ALWAYS_SHORT_PATHS: True
CONAN_USER_HOME_SHORT: "${{ github.workspace }}/conan"

BUILD_TYPE: Release
GTEST_FILTER: --gtest_filter=-"*"
CLICKHOUSE_USER: clickhouse_cpp_cicd
Expand Down Expand Up @@ -38,11 +41,20 @@ jobs:
- uses: actions/checkout@v2
- uses: ilammy/msvc-dev-cmd@v1

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON
- uses: turtlebrowser/get-conan@main

- uses: actions/[email protected]
with:
key: ${{runner.os}}-${{hashFiles('conanfile.py')}}
path: ${{env.CONAN_USER_HOME_SHORT}}

- name: Configure & Build project
run: |
mkdir -p ${{github.workspace}}/build && cd ${{github.workspace}}/build
conan install -o build_tests=True -s build_type=${{env.BUILD_TYPE}} -b missing ${{github.workspace}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
conan build ${{github.workspace}}
- name: Start tls offoader proxy
shell: bash
Expand Down
35 changes: 29 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +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)
OPTION (WITH_SYSTEM_ABSEIL "Use system ABSEIL" OFF)
OPTION (WITH_SYSTEM_LZ4 "Use system LZ4" OFF)
OPTION (WITH_SYSTEM_CITYHASH "Use system cityhash" OFF)

PROJECT (CLICKHOUSE-CLIENT)

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

IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
INCLUDE (CheckCXXSourceCompiles)

CHECK_CXX_SOURCE_COMPILES("#include <bits/c++config.h>\nint main() { return __GLIBCXX__ != 0; }"
CLANG_WITH_LIB_STDCXX)
ENDIF ()

IF (CLANG_WITH_LIB_STDCXX)
# there is a problem with __builtin_mul_overflow call at link time
# the error looks like: ... undefined reference to `__muloti4' ...
# caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404
# explicit linking to compiler-rt allows to workaround the problem
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --rtlib=compiler-rt")
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --rtlib=compiler-rt")

# some workaround for linking issues on linux:
# /usr/bin/ld: CMakeFiles/simple-test.dir/main.cpp.o: undefined reference to symbol '_Unwind_Resume@@GCC_3.0'
# /usr/bin/ld: /lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line
# FIXME: that workaround breaks clang build on mingw
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lgcc_s")
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcc_s")
ENDIF ()

INCLUDE_DIRECTORIES (.)

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

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

IF (USE_SYSTEM_CITYHASH)
IF (WITH_SYSTEM_CITYHASH)
FIND_PACKAGE(cityhash REQUIRED)
ELSE ()
INCLUDE_DIRECTORIES (contrib/cityhash/cityhash)
Expand Down
23 changes: 0 additions & 23 deletions clickhouse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,11 @@ TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static
lz4::lz4
)

IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
INCLUDE (CheckCXXSourceCompiles)

CHECK_CXX_SOURCE_COMPILES("#include <bits/c++config.h>\nint main() { return __GLIBCXX__ != 0; }"
BUILDING_WITH_LIB_STDCXX)

IF (BUILDING_WITH_LIB_STDCXX)
# there is a problem with __builtin_mul_overflow call at link time
# the error looks like: ... undefined reference to `__muloti4' ...
# caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404
# explicit linking to compiler-rt allows to workaround the problem
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --rtlib=compiler-rt")

# some workaround for linking issues on linux:
# /usr/bin/ld: CMakeFiles/simple-test.dir/main.cpp.o: undefined reference to symbol '_Unwind_Resume@@GCC_3.0'
# /usr/bin/ld: /lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line
# FIXME: that workaround breaks clang build on mingw
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib gcc_s)
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static gcc_s)
ENDIF ()
ENDIF ()

INSTALL (TARGETS clickhouse-cpp-lib clickhouse-cpp-lib-static
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)


# general
INSTALL(FILES block.h DESTINATION include/clickhouse/)
INSTALL(FILES client.h DESTINATION include/clickhouse/)
Expand Down
Loading

0 comments on commit 7fe1e84

Please sign in to comment.