-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
68 lines (51 loc) · 2.25 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 3.12)
project(clickhouse-cpp-c-bridge)
set(CMAKE_CXX_STANDARD 17)
# Required to build on linux (needs fpic)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# ========================================
# Library
# ========================================
set(LIB_SOURCES
src/main.cpp
)
add_library(${PROJECT_NAME} SHARED ${LIB_SOURCES})
# We include src/ to have absolute include paths from src/ directory instead of relative paths
# Also since our public header files use #include of external dependencies, we need to make this PUBLIC
# Otherwise, dependent projects will not be able to find the headers to build and will give errors
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/src)
# ClickHouse C++ client (copied from https://github.com/ClickHouse/clickhouse-cpp)
add_subdirectory(${PROJECT_SOURCE_DIR}/dependencies/clickhouse-cpp)
target_include_directories(${PROJECT_NAME}
PRIVATE ${PROJECT_SOURCE_DIR}/dependencies/clickhouse-cpp/
PRIVATE ${PROJECT_SOURCE_DIR}/dependencies/clickhouse-cpp/contrib/absl
)
target_link_libraries(${PROJECT_NAME}
PUBLIC clickhouse-cpp-lib
)
# ========================================
# Tests (run `ctest` in build directory)
# ========================================
enable_testing()
# Find all test files under tests/
file(GLOB_RECURSE TEST_SOURCES "tests/*.cpp")
add_executable(${PROJECT_NAME}-tests ${TEST_SOURCES})
# Link the project library
target_link_libraries(${PROJECT_NAME}-tests PRIVATE ${PROJECT_NAME})
# Doctest (https://github.com/doctest/doctest/blob/master/doc/markdown/build-systems.md)
add_subdirectory(${PROJECT_SOURCE_DIR}/dependencies/doctest)
# Include the directories for the test target
target_include_directories(${PROJECT_NAME}-tests
PRIVATE ${PROJECT_SOURCE_DIR}/dependencies/doctest
)
# These two lines are needed to find doctest_discover_tests()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/dependencies/doctest/scripts/cmake")
include(doctest)
doctest_discover_tests(${PROJECT_NAME}-tests)
# ========================================
# Code Coverage
# ========================================
if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
SET(CMAKE_CXX_FLAGS "-g -O0 --coverage")
SET(CMAKE_C_FLAGS "-g -O0 --coverage")
endif ()