Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
145 lines (116 loc) · 4.79 KB
/
Copy pathCMakeLists.txt
File metadata and controls
145 lines (116 loc) · 4.79 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
cmake_minimum_required(VERSION 3.5...3.31)
project(qore-pgsql-module)
set (VERSION_MAJOR 3)
set (VERSION_MINOR 5)
set (VERSION_PATCH 0)
set(PROJECT_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
option(enable-scu "build as a single compilation unit" ON)
option(server-includes "build with pgsql server includes" OFF)
include(CheckCXXCompilerFlag)
include(CheckCXXSourceCompiles)
include(CheckCXXSymbolExists)
include(CheckIncludeFileCXX)
# Current Qore public headers use C++17 (for example, if constexpr in QoreValue).
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
if(COMPILER_SUPPORTS_CXX17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler.")
endif()
find_package(Qore 0.9 REQUIRED)
qore_find_pthreads()
if (DEFINED ENV{PostgreSQL_INCLUDE_DIR})
set(PostgreSQL_INCLUDE_DIR $ENV{PostgreSQL_INCLUDE_DIR})
endif()
if (DEFINED ENV{PostgreSQL_TYPE_INCLUDE_DIR})
set(PostgreSQL_TYPE_INCLUDE_DIR $ENV{PostgreSQL_TYPE_INCLUDE_DIR})
endif()
if (DEFINED ENV{PostgreSQL_LIBRARY})
set(PostgreSQL_LIBRARY $ENV{PostgreSQL_LIBRARY})
endif()
find_package(PostgreSQL 8.0.0 REQUIRED)
# check if the client library has PQLibVersion
set(CMAKE_REQUIRED_INCLUDES ${PostgreSQL_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${PostgreSQL_LIBRARY})
check_cxx_symbol_exists(PQlibVersion libpq-fe.h HAVE_PQLIBVERSION)
check_cxx_symbol_exists(PQconninfo libpq-fe.h HAVE_PQCONNINFO)
check_cxx_symbol_exists(PQhostaddr libpq-fe.h HAVE_PQHOSTADDR)
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
check_include_file_cxx(arpa/inet.h HAVE_ARPA_INET_H)
check_include_file_cxx(netinet/in.h HAVE_NETINET_IN_H)
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${PostgreSQL_INCLUDE_DIRS})
add_definitions(-DQORE_MODULE_PACKAGE_VERSION="${PROJECT_VERSION}")
check_cxx_compiler_flag(-fvisibility=hidden HAVE_GCC_VISIBILITY)
configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake
${CMAKE_BINARY_DIR}/config.h)
set(QPP_SRC src/ql_pgsql.qpp src/QC_PgsqlNotificationListener.qpp)
set(CPP_SRC
src/pgsql.cpp
src/QorePGConnection.cpp
src/QorePGMapper.cpp
)
qore_wrap_qpp_value(QPP_SOURCES METALIST QPP_META_SRC DOXLIST QPP_DOX ${QPP_SRC})
add_custom_target(QPP_GENERATED_FILES DEPENDS ${QPP_SOURCES})
set(module_name "pgsql")
set(QORE_DOX_TMPL_SRC
docs/guide-pgsqlcapabilities.dox.tmpl
docs/mainpage.dox.tmpl
docs/guide-pgsqlbind.dox.tmpl
docs/guide-pgsqlbulkdml.dox.tmpl
docs/guide-pgsqlcopy.dox.tmpl
docs/guide-pgsqlmutationobserver.dox.tmpl
docs/guide-pgsqloptions.dox.tmpl
docs/guide-pgsqlreleasenotes.dox.tmpl
docs/guide-pgsqlschema.dox.tmpl
docs/guide-pgsqlstoredprocs.dox.tmpl
docs/guide-pgsqluuid.dox.tmpl
docs/guide-pgsqlvector.dox.tmpl
)
if(enable-scu)
add_library(${module_name} MODULE src/single-compilation-unit.cpp)
add_dependencies(${module_name} QPP_GENERATED_FILES)
else(enable-scu)
add_library(${module_name} MODULE ${CPP_SRC} ${QPP_SOURCES})
endif(enable-scu)
if(WIN32 OR MINGW OR MSYS)
target_compile_definitions(${module_name} PUBLIC BUILDING_DLL)
endif()
if(server-includes)
target_compile_definitions(${module_name} PUBLIC POSTGRESQL_SERVER_INCLUDES)
endif(server-includes)
if (DEFINED ENV{DOXYGEN_EXECUTABLE})
set(DOXYGEN_EXECUTABLE $ENV{DOXYGEN_EXECUTABLE})
endif()
list(APPEND QORE_DOXYGEN_MODULES BulkSqlUtil)
set(MODULE_DOX_INPUT ${CMAKE_CURRENT_BINARY_DIR}/mainpage.dox ${QPP_DOX})
list(APPEND MODULE_DOX_INPUT
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqlcapabilities.dox
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqlbind.dox
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqlbulkdml.dox
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqlcopy.dox
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqlmutationobserver.dox
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqloptions.dox
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqlreleasenotes.dox
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqlschema.dox
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqlstoredprocs.dox
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqluuid.dox
${CMAKE_CURRENT_BINARY_DIR}/guide-pgsqlvector.dox
)
qore_external_binary_module(${module_name} ${PROJECT_VERSION} ${PostgreSQL_LIBRARY} Threads::Threads)
qore_dist(${PROJECT_VERSION})
# install qpp metadata files
if (COMMAND qore_install_qpp_metadata)
qore_install_qpp_metadata(${module_name} ${QPP_META_SRC})
else()
install(FILES ${QPP_META_SRC}
DESTINATION ${CMAKE_INSTALL_DATADIR}/qore/metadata)
endif()
qore_config_info()
# NOTE: find_package(Doxygen) called in qore_external_binary_module()
if (DOXYGEN_FOUND)
qore_wrap_dox(QORE_DOX_SRC ${QORE_DOX_TMPL_SRC})
add_custom_target(QORE_MOD_DOX_FILES DEPENDS ${QORE_DOX_SRC})
add_dependencies(docs-module QORE_MOD_DOX_FILES)
endif()