-
Notifications
You must be signed in to change notification settings - Fork 40
/
CMakeLists.txt
164 lines (142 loc) · 6.53 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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR)
# Read version from version.hpp
file(READ "${CMAKE_CURRENT_LIST_DIR}/include/tao/pq/version.hpp" taopq_VERSION_DATA)
string(REGEX MATCH "#define TAO_PQ_VERSION \"([^\"]+)\"" _ ${taopq_VERSION_DATA})
set(taopq_VERSION "${CMAKE_MATCH_1}")
project(taopq VERSION ${taopq_VERSION} LANGUAGES CXX)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
find_package(PostgreSQL REQUIRED)
set(taopq_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory")
set(taopq_INSTALL_DOC_DIR "share/doc/tao/pq" CACHE STRING "The installation doc directory")
option(taopq_BUILD_TESTS "Build test programs" ON)
set(taopq_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/include)
set(taopq_INCLUDE_FILES
${taopq_INCLUDE_DIRS}/tao/pq.hpp
${taopq_INCLUDE_DIRS}/tao/pq/access_mode.hpp
${taopq_INCLUDE_DIRS}/tao/pq/binary.hpp
${taopq_INCLUDE_DIRS}/tao/pq/bind.hpp
${taopq_INCLUDE_DIRS}/tao/pq/connection.hpp
${taopq_INCLUDE_DIRS}/tao/pq/connection_pool.hpp
${taopq_INCLUDE_DIRS}/tao/pq/connection_status.hpp
${taopq_INCLUDE_DIRS}/tao/pq/exception.hpp
${taopq_INCLUDE_DIRS}/tao/pq/field.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/aggregate.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/demangle.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/exclusive_scan.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/from_chars.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/gen.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/parameter_traits_helper.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/poll.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/pool.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/resize_uninitialized.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/strtox.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/unreachable.hpp
${taopq_INCLUDE_DIRS}/tao/pq/internal/zsv.hpp
${taopq_INCLUDE_DIRS}/tao/pq/is_aggregate.hpp
${taopq_INCLUDE_DIRS}/tao/pq/is_array.hpp
${taopq_INCLUDE_DIRS}/tao/pq/isolation_level.hpp
${taopq_INCLUDE_DIRS}/tao/pq/large_object.hpp
${taopq_INCLUDE_DIRS}/tao/pq/notification.hpp
${taopq_INCLUDE_DIRS}/tao/pq/null.hpp
${taopq_INCLUDE_DIRS}/tao/pq/oid.hpp
${taopq_INCLUDE_DIRS}/tao/pq/parameter.hpp
${taopq_INCLUDE_DIRS}/tao/pq/parameter_traits.hpp
${taopq_INCLUDE_DIRS}/tao/pq/parameter_traits_aggregate.hpp
${taopq_INCLUDE_DIRS}/tao/pq/parameter_traits_array.hpp
${taopq_INCLUDE_DIRS}/tao/pq/parameter_traits_optional.hpp
${taopq_INCLUDE_DIRS}/tao/pq/parameter_traits_pair.hpp
${taopq_INCLUDE_DIRS}/tao/pq/parameter_traits_tuple.hpp
${taopq_INCLUDE_DIRS}/tao/pq/pipeline.hpp
${taopq_INCLUDE_DIRS}/tao/pq/pipeline_status.hpp
${taopq_INCLUDE_DIRS}/tao/pq/poll.hpp
${taopq_INCLUDE_DIRS}/tao/pq/result.hpp
${taopq_INCLUDE_DIRS}/tao/pq/result_status.hpp
${taopq_INCLUDE_DIRS}/tao/pq/result_traits.hpp
${taopq_INCLUDE_DIRS}/tao/pq/result_traits_aggregate.hpp
${taopq_INCLUDE_DIRS}/tao/pq/result_traits_array.hpp
${taopq_INCLUDE_DIRS}/tao/pq/result_traits_optional.hpp
${taopq_INCLUDE_DIRS}/tao/pq/result_traits_pair.hpp
${taopq_INCLUDE_DIRS}/tao/pq/result_traits_tuple.hpp
${taopq_INCLUDE_DIRS}/tao/pq/row.hpp
${taopq_INCLUDE_DIRS}/tao/pq/table_field.hpp
${taopq_INCLUDE_DIRS}/tao/pq/table_reader.hpp
${taopq_INCLUDE_DIRS}/tao/pq/table_row.hpp
${taopq_INCLUDE_DIRS}/tao/pq/table_writer.hpp
${taopq_INCLUDE_DIRS}/tao/pq/transaction.hpp
${taopq_INCLUDE_DIRS}/tao/pq/transaction_base.hpp
${taopq_INCLUDE_DIRS}/tao/pq/transaction_status.hpp
${taopq_INCLUDE_DIRS}/tao/pq/version.hpp
)
set(taopq_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/connection.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/connection_pool.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/exception.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/field.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/internal/demangle.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/internal/poll.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/internal/strtox.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/large_object.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/parameter_traits.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/pipeline.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/result.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/result_traits.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/result_traits_array.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/row.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/table_field.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/table_reader.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/table_row.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/table_writer.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/transaction.cpp
${CMAKE_CURRENT_LIST_DIR}/src/lib/pq/transaction_base.cpp
)
source_group("Header Files" FILES ${taopq_INCLUDE_FILES})
add_library(taopq ${taopq_SOURCE_FILES} ${taopq_INCLUDE_FILES})
add_library(taocpp::taopq ALIAS taopq)
set_target_properties(taopq PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")
target_include_directories(taopq
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
${PostgreSQL_INCLUDE_DIRS}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(taopq PUBLIC ${PostgreSQL_LIBRARIES})
if(WIN32)
target_link_libraries(taopq PUBLIC ws2_32)
endif()
target_compile_features(taopq PUBLIC cxx_std_20)
include(GNUInstallDirs)
set(taopq_INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} CACHE STRING "The installation cmake directory")
install(TARGETS taopq EXPORT taopq-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY include/ DESTINATION ${taopq_INSTALL_INCLUDE_DIR})
install(FILES LICENSE_1_0.txt DESTINATION ${taopq_INSTALL_DOC_DIR})
install(EXPORT taopq-targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE taocpp::
DESTINATION ${taopq_INSTALL_CONFIGDIR}
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${taopq_INSTALL_CONFIGDIR}
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${taopq_INSTALL_CONFIGDIR}
)
export(EXPORT taopq-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake NAMESPACE taocpp::)
export(PACKAGE taopq)
if(taopq_BUILD_TESTS)
enable_testing()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/src/test/pq)
endif()