-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
273 lines (223 loc) · 8.97 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
###############################################################################
# Copyright (c) 2014-2019 libbitcoin-database developers (see COPYING).
#
# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY
#
###############################################################################
# libbitcoin-database project configuration.
#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(libbitcoin-database LANGUAGES C CXX)
enable_testing()
list( APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules" )
include(CheckIncludeFiles)
include(CheckSymbolExists)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if (MSVC)
set( CANONICAL_LIB_NAME libbitcoin-database )
else ()
set( CANONICAL_LIB_NAME bitcoin-database )
find_package( PkgConfig REQUIRED )
set( prefix "${CMAKE_PREFIX_PATH}" )
set( exec_prefix "\${prefix}" )
set( libdir "\${exec_prefix}/lib" )
set( includedir "\${exec_prefix}/include" )
set( PACKAGE_VERSION "4.0.0" )
set( VERSION "${PACKAGE_VERSION}" )
endif ()
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
# Add compiler options
#------------------------------------------------------------------------------
# Warn on all stuff.
add_compile_options( "-Wall" )
# Warn on extra stuff.
add_compile_options( "-Wextra" )
# Be really annoying.
add_compile_options( "-Wpedantic" )
# Disallow warning on style order of declarations.
add_compile_options( "-Wno-reorder" )
# Suppress warning for incomplete field initialization.
add_compile_options( "-Wno-missing-field-initializers" )
# Conform to style.
add_compile_options( "-Wno-missing-braces" )
# Ignore comments within comments or commenting of backslash extended lines.
add_compile_options( "-Wno-comment" )
# Conflict in stdlib under clang.
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options( "-Wno-mismatched-tags" )
endif()
# Implement -Dpkgconfigdir and output ${pkgconfigdir}.
#------------------------------------------------------------------------------
set( pkgconfigdir "${libdir}/pkgconfig" CACHE PATH "Path to pkgconfig directory." )
# Implement -Dwith-tests and declare with-tests.
#------------------------------------------------------------------------------
set( with-tests "yes" CACHE BOOL "Compile with unit tests." )
# Implement -Dwith-tools and declare with-tools.
#------------------------------------------------------------------------------
set( with-tools "yes" CACHE BOOL "Compile with tools." )
# Implement -Denable-ndebug and define NDEBUG.
#------------------------------------------------------------------------------
set( enable-ndebug "yes" CACHE BOOL "Compile without debug assertions." )
if (enable-ndebug)
add_definitions( -DNDEBUG )
endif()
# Inherit -Denable-shared and define BOOST_ALL_DYN_LINK.
#------------------------------------------------------------------------------
if (BUILD_SHARED_LIBS)
add_definitions( -DBOOST_ALL_DYN_LINK )
endif()
# Find boost
#------------------------------------------------------------------------------
find_package( Boost 1.62.0 REQUIRED COMPONENTS
unit_test_framework )
set( boost_unit_test_framework_LIBS "-lboost_unit_test_framework" )
if (enable-ndebug)
set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_DEBUG}" )
else ()
set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_RELEASE}" )
endif()
set( boost_CPPFLAGS "-I${Boost_INCLUDE_DIR}" )
set( boost_LDFLAGS "-L${Boost_LIBRARY_DIR}" )
# Find bitcoin-system
#------------------------------------------------------------------------------
find_package( Bitcoin-System 4.0.0 REQUIRED )
# Define project common includes directories
#------------------------------------------------------------------------------
if (BUILD_SHARED_LIBS)
include_directories( SYSTEM
${bitcoin_system_INCLUDE_DIRS} )
else()
include_directories( SYSTEM
${bitcoin_system_STATIC_INCLUDE_DIRS} )
endif()
# Define project common library directories
#------------------------------------------------------------------------------
if (BUILD_SHARED_LIBS)
link_directories(
${bitcoin_system_LIBRARY_DIRS} )
else()
link_directories(
${bitcoin_system_STATIC_LIBRARY_DIRS} )
endif()
# Define project common libraries/linker flags.
#------------------------------------------------------------------------------
if (BUILD_SHARED_LIBS)
link_libraries(
"-fstack-protector"
"-fstack-protector-all"
${bitcoin_system_LIBRARIES} )
else()
link_libraries(
"-fstack-protector"
"-fstack-protector-all"
${bitcoin_system_STATIC_LIBRARIES} )
endif()
# Define ${CANONICAL_LIB_NAME} project.
#------------------------------------------------------------------------------
add_library( ${CANONICAL_LIB_NAME}
"./src/database/transaction_management/transaction_context.cpp"
"./src/database/transaction_management/transaction_manager.cpp"
"./src/database/tuples/block_tuple.cpp"
"./src/database/databases/block_database.cpp"
"./src/database/storage/util.cpp"
)
# ${CANONICAL_LIB_NAME} project specific include directories.
#------------------------------------------------------------------------------
if (BUILD_SHARED_LIBS)
target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE
"./include"
${bitcoin_system_INCLUDE_DIRS} )
else()
target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE
"./include"
${bitcoin_system_STATIC_INCLUDE_DIRS} )
endif()
target_include_directories( ${CANONICAL_LIB_NAME} PUBLIC
"./include" )
# ${CANONICAL_LIB_NAME} project specific libraries/linker flags.
#------------------------------------------------------------------------------
if (BUILD_SHARED_LIBS)
target_link_libraries( ${CANONICAL_LIB_NAME}
${bitcoin_system_LIBRARIES} )
else()
target_link_libraries( ${CANONICAL_LIB_NAME}
${bitcoin_system_STATIC_LIBRARIES} )
endif()
# Define libbitcoin-mvcc-database-test project.
# ------------------------------------------------------------------------------
if (with-tests)
add_executable( libbitcoin-mvcc-database-test
"./test/main.cpp"
"./test/databases/block_database.cpp"
"./test/transaction_management/transaction_manager.cpp"
"./test/transaction_management/transaction_context.cpp"
"./test/tuples/mvcc_record.cpp"
"./test/tuples/block_tuple.cpp"
"./test/storage/object_pool.cpp"
"./test/storage/raw_block.cpp"
"./test/container/concurrent_bitmap.cpp"
"./test/storage/storage.cpp"
"./test/mvto/accessor.cpp"
)
add_test( NAME libbitcoin-mvcc-database-test COMMAND libbitcoin-mvcc-database-test
--run_test=*
--show_progress=yes
--detect_memory_leak=0
--report_level=no
--build_info=yes )
# libbitcoin-mvcc-database-test project specific include directories.
# ------------------------------------------------------------------------------
target_include_directories( libbitcoin-mvcc-database-test PRIVATE
"./include" )
# libbitcoin-mvcc-database-test project specific libraries/linker flags.
#------------------------------------------------------------------------------
target_link_libraries( libbitcoin-mvcc-database-test
${CANONICAL_LIB_NAME}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} )
endif()
# Define initchain project.
#------------------------------------------------------------------------------
# if (with-tools)
# add_executable( initchain
# "./tools/initchain/initchain"
# "./tools/initchain/initchain-initchain.o"
# "./tools/initchain/initchain.cpp" )
# initchain project specific include directories.
#------------------------------------------------------------------------------
# target_include_directories( initchain PRIVATE
# "./include" )
# initchain project specific libraries/linker flags.
#------------------------------------------------------------------------------
# target_link_libraries( initchain
# ${CANONICAL_LIB_NAME} )
# endif()
# Manage pkgconfig installation.
#------------------------------------------------------------------------------
configure_file(
"./libbitcoin-database.pc.in"
"libbitcoin-database.pc" @ONLY )
install( FILES
"${CMAKE_CURRENT_BINARY_DIR}/libbitcoin-database.pc"
DESTINATION "${pkgconfigdir}" )
# Manage installation of docs.
#------------------------------------------------------------------------------
install( FILES
"./AUTHORS"
"./COPYING"
"./ChangeLog"
"./INSTALL"
"./NEWS"
"./README"
DESTINATION share/doc/libbitcoin-database )
# Manage ${CANONICAL_LIB_NAME} installation.
#------------------------------------------------------------------------------
install( TARGETS ${CANONICAL_LIB_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include )
# Manage include installation.
#------------------------------------------------------------------------------
install( DIRECTORY "./include/bitcoin"
DESTINATION include )