-
Notifications
You must be signed in to change notification settings - Fork 55
/
CMakeLists.txt
75 lines (63 loc) · 2.87 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
69
70
71
72
73
74
75
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(clickhouse_fdw VERSION 1.4.0 LANGUAGES C)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
message(STATUS "Setting ${CMAKE_PROJECT_NAME} build type - ${CMAKE_BUILD_TYPE}")
#------------------------------------------------------------------------------
# PostgreSQL server paths come from pg_config
#------------------------------------------------------------------------------
find_program(PG_CONFIG pg_config)
if(NOT PG_CONFIG)
message(FATAL_ERROR "Unable to find 'pg_config'")
endif(NOT PG_CONFIG)
exec_program(${PG_CONFIG} ARGS --version OUTPUT_VARIABLE PGCONFIG_OUTPUT)
string(REGEX REPLACE
"^PostgreSQL[\t ]+([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1.\\2.\\3"
PGSQL_VERSION "${PGCONFIG_OUTPUT}")
unset(PGCONFIG_OUTPUT)
if(PGSQL_VERSION)
string(REGEX REPLACE
"([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1"
PGSQL_VERSION_MAJOR "${PGSQL_VERSION}")
string(REGEX REPLACE
"([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2"
PGSQL_VERSION_MINOR "${PGSQL_VERSION}")
set(PGSQL_NUMERIC_VERSION ${PGSQL_VERSION_MAJOR}${PGSQL_VERSION_MINOR})
endif()
exec_program(${PG_CONFIG} ARGS --includedir OUTPUT_VARIABLE PGSQL_INCLUDEDIR)
exec_program(${PG_CONFIG} ARGS --includedir-server
OUTPUT_VARIABLE PGSQL_INCLUDEDIR_SERVER)
exec_program(${PG_CONFIG} ARGS --libdir OUTPUT_VARIABLE PGSQL_LIBDIR)
exec_program(${PG_CONFIG} ARGS --pkglibdir OUTPUT_VARIABLE PGSQL_PKGLIBDIR)
exec_program(${PG_CONFIG} ARGS --sharedir OUTPUT_VARIABLE PGSQL_SHAREDIR)
exec_program(${PG_CONFIG} ARGS --bindir OUTPUT_VARIABLE PGSQL_BINDIR)
exec_program(${PG_CONFIG} ARGS --cppflags OUTPUT_VARIABLE PGSQL_CPPFLAGS)
exec_program(${PG_CONFIG} ARGS --ldflags OUTPUT_VARIABLE PGSQL_LDFLAGS)
exec_program(${PG_CONFIG} ARGS --libs OUTPUT_VARIABLE PGSQL_LIBS)
#------------------------------------------------------------------------------
# tests
#------------------------------------------------------------------------------
find_program(PG_REGRESS NAMES pg_regress PATHS ${PGSQL_PKGLIBDIR}/pgxs/src/test/regress/ REQUIRED)
LIST(APPEND REGRESS_TESTS
http
binary
import_schema
binary_queries
binary_inserts
functions
engines
deparse_checks
)
add_custom_target(installcheck
COMMAND ${PG_REGRESS} --inputdir=${PROJECT_SOURCE_DIR}/tests --outputdir=${PROJECT_SOURCE_DIR}/tests \${EXTRA_REGRESS_OPTS} ${REGRESS_TESTS})
#------------------------------------------------------------------------------
# use default install location if not specified
#------------------------------------------------------------------------------
if (NOT DEFINED LIB_INSTALL_DIR)
set (LIB_INSTALL_DIR lib)
endif()
#------------------------------------------------------------------------------
# source dir
#------------------------------------------------------------------------------
add_subdirectory (src)