-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
77 lines (64 loc) · 2.53 KB
/
CMakeLists.txt
File metadata and controls
77 lines (64 loc) · 2.53 KB
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
69
70
71
72
73
74
75
76
cmake_minimum_required(VERSION 3.16)
project(pg_stat_ch VERSION 0.1.0 LANGUAGES CXX C)
if(WIN32)
message(FATAL_ERROR "Windows is not supported")
endif()
# Add cmake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Get version from git
include(GitVersion)
get_git_version(GIT_VERSION)
message(STATUS "Version: ${GIT_VERSION}")
# Find PostgreSQL
find_package(PostgreSQLServer REQUIRED)
message(STATUS "PostgreSQL ${PostgreSQLServer_VERSION} found")
# Compiler warnings
include(CompilerWarnings)
# OpenSSL (required — vcpkg manifest always builds clickhouse-cpp with openssl)
find_package(OpenSSL REQUIRED)
message(STATUS "OpenSSL ${OPENSSL_VERSION} found")
# ---------------------------------------------------------------------------
# Third-party dependencies (via vcpkg)
# ---------------------------------------------------------------------------
find_package(opentelemetry-cpp CONFIG REQUIRED)
find_package(ClickHouseCpp REQUIRED)
find_package(Arrow CONFIG REQUIRED)
# Collect source files
file(GLOB_RECURSE SOURCES src/*.cc src/*.c)
# Build shared library
add_library(pg_stat_ch SHARED ${SOURCES})
target_compile_features(pg_stat_ch PRIVATE cxx_std_17)
target_compile_definitions(pg_stat_ch PRIVATE PG_STAT_CH_VERSION="${GIT_VERSION}")
# Force-include libintl.h before any source file so its declarations are parsed
# before PostgreSQL's postgres.h defines gettext/ngettext as macros. The include
# guard then prevents re-inclusion when C++ <locale> pulls it in later (via Arrow).
target_compile_options(pg_stat_ch PRIVATE -include libintl.h)
target_include_directories(pg_stat_ch PRIVATE
include
src
)
target_link_libraries(pg_stat_ch PRIVATE
PostgreSQLServer::PostgreSQLServer
ClickHouseCpp::ClickHouseCpp
opentelemetry-cpp::api
opentelemetry-cpp::sdk
opentelemetry-cpp::otlp_grpc_metrics_exporter
opentelemetry-cpp::otlp_grpc_log_record_exporter
opentelemetry-cpp::metrics
opentelemetry-cpp::logs
Arrow::arrow_static
)
target_link_libraries(pg_stat_ch PRIVATE OpenSSL::SSL OpenSSL::Crypto)
pg_stat_ch_set_warnings(pg_stat_ch)
set_target_properties(pg_stat_ch PROPERTIES
PREFIX ""
SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}"
)
if(APPLE)
target_link_options(pg_stat_ch PRIVATE -undefined dynamic_lookup)
endif()
# Install targets
install(TARGETS pg_stat_ch LIBRARY DESTINATION ${PostgreSQLServer_PKGLIB_DIR})
install(FILES pg_stat_ch.control DESTINATION ${PostgreSQLServer_SHARE_DIR}/extension)
file(GLOB SQL_FILES sql/pg_stat_ch--*.sql)
install(FILES ${SQL_FILES} DESTINATION ${PostgreSQLServer_SHARE_DIR}/extension)