|
| 1 | +############################################################################### |
| 2 | +# Copyright (c) 2014-2020 libbitcoin-database developers (see COPYING). |
| 3 | +# |
| 4 | +# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY |
| 5 | +# |
| 6 | +############################################################################### |
| 7 | + |
| 8 | +# libbitcoin-database project configuration. |
| 9 | +#------------------------------------------------------------------------------ |
| 10 | +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) |
| 11 | + |
| 12 | +project(libbitcoin-database LANGUAGES C CXX) |
| 13 | + |
| 14 | +enable_testing() |
| 15 | + |
| 16 | +list( APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules" ) |
| 17 | +include(CheckIncludeFiles) |
| 18 | +include(CheckSymbolExists) |
| 19 | + |
| 20 | +set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 21 | + |
| 22 | +if (MSVC) |
| 23 | + set( CANONICAL_LIB_NAME libbitcoin-database ) |
| 24 | +else () |
| 25 | + set( CANONICAL_LIB_NAME bitcoin-database ) |
| 26 | + find_package( PkgConfig REQUIRED ) |
| 27 | + |
| 28 | + set( prefix "${CMAKE_PREFIX_PATH}" ) |
| 29 | + set( exec_prefix "\${prefix}" ) |
| 30 | + set( libdir "\${exec_prefix}/lib" ) |
| 31 | + set( includedir "\${exec_prefix}/include" ) |
| 32 | + |
| 33 | + set( PACKAGE_VERSION "4.0.0" ) |
| 34 | + set( VERSION "${PACKAGE_VERSION}" ) |
| 35 | +endif () |
| 36 | + |
| 37 | +set( CMAKE_CXX_STANDARD 11 ) |
| 38 | +set( CMAKE_CXX_STANDARD_REQUIRED ON ) |
| 39 | + |
| 40 | +# Add compiler options |
| 41 | +#------------------------------------------------------------------------------ |
| 42 | +# Warn on all stuff. |
| 43 | +add_compile_options( "-Wall" ) |
| 44 | + |
| 45 | +# Warn on extra stuff. |
| 46 | +add_compile_options( "-Wextra" ) |
| 47 | + |
| 48 | +# Be really annoying. |
| 49 | +add_compile_options( "-Wpedantic" ) |
| 50 | + |
| 51 | +# Disallow warning on style order of declarations. |
| 52 | +add_compile_options( "-Wno-reorder" ) |
| 53 | + |
| 54 | +# Suppress warning for incomplete field initialization. |
| 55 | +add_compile_options( "-Wno-missing-field-initializers" ) |
| 56 | + |
| 57 | +# Conform to style. |
| 58 | +add_compile_options( "-Wno-missing-braces" ) |
| 59 | + |
| 60 | +# Ignore comments within comments or commenting of backslash extended lines. |
| 61 | +add_compile_options( "-Wno-comment" ) |
| 62 | + |
| 63 | +# Conflict in stdlib under clang. |
| 64 | +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") |
| 65 | + add_compile_options( "-Wno-mismatched-tags" ) |
| 66 | +endif() |
| 67 | + |
| 68 | +# Implement -Dpkgconfigdir and output ${pkgconfigdir}. |
| 69 | +#------------------------------------------------------------------------------ |
| 70 | +set( pkgconfigdir "${libdir}/pkgconfig" CACHE PATH "Path to pkgconfig directory." ) |
| 71 | + |
| 72 | +# Implement -Dwith-tests and declare with-tests. |
| 73 | +#------------------------------------------------------------------------------ |
| 74 | +set( with-tests "yes" CACHE BOOL "Compile with unit tests." ) |
| 75 | + |
| 76 | +# Implement -Dwith-tools and declare with-tools. |
| 77 | +#------------------------------------------------------------------------------ |
| 78 | +set( with-tools "yes" CACHE BOOL "Compile with tools." ) |
| 79 | + |
| 80 | +# Implement -Denable-ndebug and define NDEBUG. |
| 81 | +#------------------------------------------------------------------------------ |
| 82 | +set( enable-ndebug "yes" CACHE BOOL "Compile without debug assertions." ) |
| 83 | + |
| 84 | +if (enable-ndebug) |
| 85 | + add_definitions( -DNDEBUG ) |
| 86 | +endif() |
| 87 | + |
| 88 | +# Inherit -Denable-shared and define BOOST_ALL_DYN_LINK. |
| 89 | +#------------------------------------------------------------------------------ |
| 90 | +if (BUILD_SHARED_LIBS) |
| 91 | + add_definitions( -DBOOST_ALL_DYN_LINK ) |
| 92 | +endif() |
| 93 | + |
| 94 | +# Find boost |
| 95 | +#------------------------------------------------------------------------------ |
| 96 | +find_package( Boost 1.72.0 REQUIRED COMPONENTS |
| 97 | + unit_test_framework ) |
| 98 | + |
| 99 | +set( boost_unit_test_framework_LIBS "-lboost_unit_test_framework" ) |
| 100 | + |
| 101 | +if (enable-ndebug) |
| 102 | + set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_DEBUG}" ) |
| 103 | +else () |
| 104 | + set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_RELEASE}" ) |
| 105 | +endif() |
| 106 | + |
| 107 | +set( boost_CPPFLAGS "-I${Boost_INCLUDE_DIR}" ) |
| 108 | +set( boost_LDFLAGS "-L${Boost_LIBRARY_DIR}" ) |
| 109 | + |
| 110 | +# Find bitcoin-system |
| 111 | +#------------------------------------------------------------------------------ |
| 112 | +find_package( Bitcoin-System 4.0.0 REQUIRED ) |
| 113 | + |
| 114 | +# Define project common includes directories |
| 115 | +#------------------------------------------------------------------------------ |
| 116 | +if (BUILD_SHARED_LIBS) |
| 117 | + include_directories( SYSTEM |
| 118 | + ${bitcoin_system_INCLUDE_DIRS} ) |
| 119 | +else() |
| 120 | + include_directories( SYSTEM |
| 121 | + ${bitcoin_system_STATIC_INCLUDE_DIRS} ) |
| 122 | +endif() |
| 123 | + |
| 124 | +# Define project common library directories |
| 125 | +#------------------------------------------------------------------------------ |
| 126 | +if (BUILD_SHARED_LIBS) |
| 127 | + link_directories( |
| 128 | + ${bitcoin_system_LIBRARY_DIRS} ) |
| 129 | +else() |
| 130 | + link_directories( |
| 131 | + ${bitcoin_system_STATIC_LIBRARY_DIRS} ) |
| 132 | +endif() |
| 133 | + |
| 134 | +# Define project common libraries/linker flags. |
| 135 | +#------------------------------------------------------------------------------ |
| 136 | +if (BUILD_SHARED_LIBS) |
| 137 | + link_libraries( |
| 138 | + "-fstack-protector" |
| 139 | + "-fstack-protector-all" |
| 140 | + ${bitcoin_system_LIBRARIES} ) |
| 141 | +else() |
| 142 | + link_libraries( |
| 143 | + "-fstack-protector" |
| 144 | + "-fstack-protector-all" |
| 145 | + ${bitcoin_system_STATIC_LIBRARIES} ) |
| 146 | +endif() |
| 147 | + |
| 148 | +# Define ${CANONICAL_LIB_NAME} project. |
| 149 | +#------------------------------------------------------------------------------ |
| 150 | +add_library( ${CANONICAL_LIB_NAME} |
| 151 | + "../../src/data_base.cpp" |
| 152 | + "../../src/settings.cpp" |
| 153 | + "../../src/store.cpp" |
| 154 | + "../../src/unspent_outputs.cpp" |
| 155 | + "../../src/unspent_transaction.cpp" |
| 156 | + "../../src/databases/block_database.cpp" |
| 157 | + "../../src/databases/history_database.cpp" |
| 158 | + "../../src/databases/spend_database.cpp" |
| 159 | + "../../src/databases/stealth_database.cpp" |
| 160 | + "../../src/databases/transaction_database.cpp" |
| 161 | + "../../src/memory/accessor.cpp" |
| 162 | + "../../src/memory/allocator.cpp" |
| 163 | + "../../src/memory/memory_map.cpp" |
| 164 | + "../../src/mman-win32/mman.c" |
| 165 | + "../../src/mman-win32/mman.h" |
| 166 | + "../../src/primitives/record_list.cpp" |
| 167 | + "../../src/primitives/record_manager.cpp" |
| 168 | + "../../src/primitives/record_multimap_iterable.cpp" |
| 169 | + "../../src/primitives/record_multimap_iterator.cpp" |
| 170 | + "../../src/primitives/slab_manager.cpp" |
| 171 | + "../../src/result/block_result.cpp" |
| 172 | + "../../src/result/transaction_result.cpp" ) |
| 173 | + |
| 174 | +# ${CANONICAL_LIB_NAME} project specific include directories. |
| 175 | +#------------------------------------------------------------------------------ |
| 176 | +if (BUILD_SHARED_LIBS) |
| 177 | + target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE |
| 178 | + "../../include" |
| 179 | + ${bitcoin_system_INCLUDE_DIRS} ) |
| 180 | +else() |
| 181 | + target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE |
| 182 | + "../../include" |
| 183 | + ${bitcoin_system_STATIC_INCLUDE_DIRS} ) |
| 184 | +endif() |
| 185 | + |
| 186 | +target_include_directories( ${CANONICAL_LIB_NAME} PUBLIC |
| 187 | +"../../include" ) |
| 188 | + |
| 189 | +# ${CANONICAL_LIB_NAME} project specific libraries/linker flags. |
| 190 | +#------------------------------------------------------------------------------ |
| 191 | +if (BUILD_SHARED_LIBS) |
| 192 | + target_link_libraries( ${CANONICAL_LIB_NAME} |
| 193 | + ${bitcoin_system_LIBRARIES} ) |
| 194 | +else() |
| 195 | + target_link_libraries( ${CANONICAL_LIB_NAME} |
| 196 | + ${bitcoin_system_STATIC_LIBRARIES} ) |
| 197 | +endif() |
| 198 | + |
| 199 | +# Define libbitcoin-database-test project. |
| 200 | +#------------------------------------------------------------------------------ |
| 201 | +if (with-tests) |
| 202 | + add_executable( libbitcoin-database-test |
| 203 | + "../../test/block_database.cpp" |
| 204 | + "../../test/data_base.cpp" |
| 205 | + "../../test/hash_table.cpp" |
| 206 | + "../../test/history_database.cpp" |
| 207 | + "../../test/main.cpp" |
| 208 | + "../../test/spend_database.cpp" |
| 209 | + "../../test/structure.cpp" |
| 210 | + "../../test/transaction_database.cpp" |
| 211 | + "../../test/unspent_outputs.cpp" |
| 212 | + "../../test/unspent_transaction.cpp" ) |
| 213 | + |
| 214 | + add_test( NAME libbitcoin-database-test COMMAND libbitcoin-database-test |
| 215 | + --run_test=* |
| 216 | + --show_progress=no |
| 217 | + --detect_memory_leak=0 |
| 218 | + --report_level=no |
| 219 | + --build_info=yes ) |
| 220 | + |
| 221 | +# libbitcoin-database-test project specific include directories. |
| 222 | +#------------------------------------------------------------------------------ |
| 223 | + target_include_directories( libbitcoin-database-test PRIVATE |
| 224 | + "../../include" ) |
| 225 | + |
| 226 | +# libbitcoin-database-test project specific libraries/linker flags. |
| 227 | +#------------------------------------------------------------------------------ |
| 228 | + target_link_libraries( libbitcoin-database-test |
| 229 | + ${CANONICAL_LIB_NAME} |
| 230 | + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ) |
| 231 | + |
| 232 | +endif() |
| 233 | + |
| 234 | +# Define initchain project. |
| 235 | +#------------------------------------------------------------------------------ |
| 236 | +if (with-tools) |
| 237 | + add_executable( initchain |
| 238 | + "../../tools/initchain/initchain.cpp" ) |
| 239 | + |
| 240 | +# initchain project specific include directories. |
| 241 | +#------------------------------------------------------------------------------ |
| 242 | + target_include_directories( initchain PRIVATE |
| 243 | + "../../include" ) |
| 244 | + |
| 245 | +# initchain project specific libraries/linker flags. |
| 246 | +#------------------------------------------------------------------------------ |
| 247 | + target_link_libraries( initchain |
| 248 | + ${CANONICAL_LIB_NAME} ) |
| 249 | + |
| 250 | +endif() |
| 251 | + |
| 252 | +# Manage pkgconfig installation. |
| 253 | +#------------------------------------------------------------------------------ |
| 254 | +configure_file( |
| 255 | + "../../libbitcoin-database.pc.in" |
| 256 | + "libbitcoin-database.pc" @ONLY ) |
| 257 | + |
| 258 | +install( FILES |
| 259 | + "${CMAKE_CURRENT_BINARY_DIR}/libbitcoin-database.pc" |
| 260 | + DESTINATION "${pkgconfigdir}" ) |
| 261 | + |
| 262 | +# Manage installation of docs. |
| 263 | +#------------------------------------------------------------------------------ |
| 264 | +install( FILES |
| 265 | + "../../AUTHORS" |
| 266 | + "../../COPYING" |
| 267 | + "../../ChangeLog" |
| 268 | + "../../INSTALL" |
| 269 | + "../../NEWS" |
| 270 | + "../../README" |
| 271 | + DESTINATION share/doc/libbitcoin-database ) |
| 272 | + |
| 273 | +# Manage ${CANONICAL_LIB_NAME} installation. |
| 274 | +#------------------------------------------------------------------------------ |
| 275 | +install( TARGETS ${CANONICAL_LIB_NAME} |
| 276 | + RUNTIME DESTINATION bin |
| 277 | + LIBRARY DESTINATION lib |
| 278 | + ARCHIVE DESTINATION lib |
| 279 | + PUBLIC_HEADER DESTINATION include ) |
| 280 | + |
| 281 | +# Manage include installation. |
| 282 | +#------------------------------------------------------------------------------ |
| 283 | +install( DIRECTORY "../../include/bitcoin" |
| 284 | + DESTINATION include ) |
| 285 | + |
0 commit comments