|
| 1 | +############################################################################### |
| 2 | +# Copyright (c) 2014-2020 libbitcoin-node developers (see COPYING). |
| 3 | +# |
| 4 | +# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY |
| 5 | +# |
| 6 | +############################################################################### |
| 7 | + |
| 8 | +# libbitcoin-node project configuration. |
| 9 | +#------------------------------------------------------------------------------ |
| 10 | +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) |
| 11 | + |
| 12 | +project(libbitcoin-node 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-node ) |
| 24 | +else () |
| 25 | + set( CANONICAL_LIB_NAME bitcoin-node ) |
| 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 -Dbash-completiondir and output ${bash-completiondir} and declare bash-completiondir. |
| 69 | +#------------------------------------------------------------------------------ |
| 70 | +set( bash-completiondir "no" CACHE BOOL "Install bash completion support, optionally specifying the directory. This option may require elevated permissions." ) |
| 71 | + |
| 72 | +# Implement -Dpkgconfigdir and output ${pkgconfigdir}. |
| 73 | +#------------------------------------------------------------------------------ |
| 74 | +set( pkgconfigdir "${libdir}/pkgconfig" CACHE PATH "Path to pkgconfig directory." ) |
| 75 | + |
| 76 | +# Implement -Dwith-tests and declare with-tests. |
| 77 | +#------------------------------------------------------------------------------ |
| 78 | +set( with-tests "yes" CACHE BOOL "Compile with unit tests." ) |
| 79 | + |
| 80 | +# Implement -Dwith-console and declare with-console. |
| 81 | +#------------------------------------------------------------------------------ |
| 82 | +set( with-console "yes" CACHE BOOL "Compile console application." ) |
| 83 | + |
| 84 | +# Implement -Denable-ndebug and define NDEBUG. |
| 85 | +#------------------------------------------------------------------------------ |
| 86 | +set( enable-ndebug "yes" CACHE BOOL "Compile without debug assertions." ) |
| 87 | + |
| 88 | +if (enable-ndebug) |
| 89 | + add_definitions( -DNDEBUG ) |
| 90 | +endif() |
| 91 | + |
| 92 | +# Inherit -Denable-shared and define BOOST_ALL_DYN_LINK. |
| 93 | +#------------------------------------------------------------------------------ |
| 94 | +if (BUILD_SHARED_LIBS) |
| 95 | + add_definitions( -DBOOST_ALL_DYN_LINK ) |
| 96 | +endif() |
| 97 | + |
| 98 | +# Find boost |
| 99 | +#------------------------------------------------------------------------------ |
| 100 | +find_package( Boost 1.72.0 REQUIRED COMPONENTS |
| 101 | + unit_test_framework ) |
| 102 | + |
| 103 | +set( boost_unit_test_framework_LIBS "-lboost_unit_test_framework" ) |
| 104 | + |
| 105 | +if (enable-ndebug) |
| 106 | + set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_DEBUG}" ) |
| 107 | +else () |
| 108 | + set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_RELEASE}" ) |
| 109 | +endif() |
| 110 | + |
| 111 | +set( boost_CPPFLAGS "-I${Boost_INCLUDE_DIR}" ) |
| 112 | +set( boost_LDFLAGS "-L${Boost_LIBRARY_DIR}" ) |
| 113 | + |
| 114 | +# Find bash-completion |
| 115 | +#------------------------------------------------------------------------------ |
| 116 | +if (bash-completiondir) |
| 117 | + find_package( Bash-Completion 2.0.0 REQUIRED ) |
| 118 | +endif() |
| 119 | + |
| 120 | +# Find bitcoin-blockchain |
| 121 | +#------------------------------------------------------------------------------ |
| 122 | +find_package( Bitcoin-Blockchain 4.0.0 REQUIRED ) |
| 123 | + |
| 124 | +# Find bitcoin-network |
| 125 | +#------------------------------------------------------------------------------ |
| 126 | +find_package( Bitcoin-Network 4.0.0 REQUIRED ) |
| 127 | + |
| 128 | +# Define project common includes directories |
| 129 | +#------------------------------------------------------------------------------ |
| 130 | +if (BUILD_SHARED_LIBS) |
| 131 | + include_directories( SYSTEM |
| 132 | + ${bitcoin_blockchain_INCLUDE_DIRS} |
| 133 | + ${bitcoin_network_INCLUDE_DIRS} ) |
| 134 | +else() |
| 135 | + include_directories( SYSTEM |
| 136 | + ${bitcoin_blockchain_STATIC_INCLUDE_DIRS} |
| 137 | + ${bitcoin_network_STATIC_INCLUDE_DIRS} ) |
| 138 | +endif() |
| 139 | + |
| 140 | +# Define project common library directories |
| 141 | +#------------------------------------------------------------------------------ |
| 142 | +if (BUILD_SHARED_LIBS) |
| 143 | + link_directories( |
| 144 | + ${bitcoin_blockchain_LIBRARY_DIRS} |
| 145 | + ${bitcoin_network_LIBRARY_DIRS} ) |
| 146 | +else() |
| 147 | + link_directories( |
| 148 | + ${bitcoin_blockchain_STATIC_LIBRARY_DIRS} |
| 149 | + ${bitcoin_network_STATIC_LIBRARY_DIRS} ) |
| 150 | +endif() |
| 151 | + |
| 152 | +# Define project common libraries/linker flags. |
| 153 | +#------------------------------------------------------------------------------ |
| 154 | +if (BUILD_SHARED_LIBS) |
| 155 | + link_libraries( |
| 156 | + "-fstack-protector" |
| 157 | + "-fstack-protector-all" |
| 158 | + ${bitcoin_blockchain_LIBRARIES} |
| 159 | + ${bitcoin_network_LIBRARIES} ) |
| 160 | +else() |
| 161 | + link_libraries( |
| 162 | + "-fstack-protector" |
| 163 | + "-fstack-protector-all" |
| 164 | + ${bitcoin_blockchain_STATIC_LIBRARIES} |
| 165 | + ${bitcoin_network_STATIC_LIBRARIES} ) |
| 166 | +endif() |
| 167 | + |
| 168 | +add_definitions( |
| 169 | + -DSYSCONFDIR=\"${sysconfdir}\" ) |
| 170 | + |
| 171 | +# Define ${CANONICAL_LIB_NAME} project. |
| 172 | +#------------------------------------------------------------------------------ |
| 173 | +add_library( ${CANONICAL_LIB_NAME} |
| 174 | + "../../src/configuration.cpp" |
| 175 | + "../../src/full_node.cpp" |
| 176 | + "../../src/parser.cpp" |
| 177 | + "../../src/settings.cpp" |
| 178 | + "../../src/protocols/protocol_block_in.cpp" |
| 179 | + "../../src/protocols/protocol_block_out.cpp" |
| 180 | + "../../src/protocols/protocol_block_sync.cpp" |
| 181 | + "../../src/protocols/protocol_header_sync.cpp" |
| 182 | + "../../src/protocols/protocol_transaction_in.cpp" |
| 183 | + "../../src/protocols/protocol_transaction_out.cpp" |
| 184 | + "../../src/sessions/session_block_sync.cpp" |
| 185 | + "../../src/sessions/session_header_sync.cpp" |
| 186 | + "../../src/sessions/session_inbound.cpp" |
| 187 | + "../../src/sessions/session_manual.cpp" |
| 188 | + "../../src/sessions/session_outbound.cpp" |
| 189 | + "../../src/utility/check_list.cpp" |
| 190 | + "../../src/utility/header_list.cpp" |
| 191 | + "../../src/utility/performance.cpp" |
| 192 | + "../../src/utility/reservation.cpp" |
| 193 | + "../../src/utility/reservations.cpp" ) |
| 194 | + |
| 195 | +# ${CANONICAL_LIB_NAME} project specific include directories. |
| 196 | +#------------------------------------------------------------------------------ |
| 197 | +if (BUILD_SHARED_LIBS) |
| 198 | + target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE |
| 199 | + "../../include" |
| 200 | + ${bitcoin_blockchain_INCLUDE_DIRS} |
| 201 | + ${bitcoin_network_INCLUDE_DIRS} ) |
| 202 | +else() |
| 203 | + target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE |
| 204 | + "../../include" |
| 205 | + ${bitcoin_blockchain_STATIC_INCLUDE_DIRS} |
| 206 | + ${bitcoin_network_STATIC_INCLUDE_DIRS} ) |
| 207 | +endif() |
| 208 | + |
| 209 | +target_include_directories( ${CANONICAL_LIB_NAME} PUBLIC |
| 210 | +"../../include" ) |
| 211 | + |
| 212 | +# ${CANONICAL_LIB_NAME} project specific libraries/linker flags. |
| 213 | +#------------------------------------------------------------------------------ |
| 214 | +if (BUILD_SHARED_LIBS) |
| 215 | + target_link_libraries( ${CANONICAL_LIB_NAME} |
| 216 | + ${bitcoin_blockchain_LIBRARIES} |
| 217 | + ${bitcoin_network_LIBRARIES} ) |
| 218 | +else() |
| 219 | + target_link_libraries( ${CANONICAL_LIB_NAME} |
| 220 | + ${bitcoin_blockchain_STATIC_LIBRARIES} |
| 221 | + ${bitcoin_network_STATIC_LIBRARIES} ) |
| 222 | +endif() |
| 223 | + |
| 224 | +# Define libbitcoin-node-test project. |
| 225 | +#------------------------------------------------------------------------------ |
| 226 | +if (with-tests) |
| 227 | + add_executable( libbitcoin-node-test |
| 228 | + "../../test/check_list.cpp" |
| 229 | + "../../test/configuration.cpp" |
| 230 | + "../../test/header_list.cpp" |
| 231 | + "../../test/main.cpp" |
| 232 | + "../../test/node.cpp" |
| 233 | + "../../test/performance.cpp" |
| 234 | + "../../test/reservation.cpp" |
| 235 | + "../../test/reservations.cpp" |
| 236 | + "../../test/settings.cpp" |
| 237 | + "../../test/utility.cpp" |
| 238 | + "../../test/utility.hpp" ) |
| 239 | + |
| 240 | + add_test( NAME libbitcoin-node-test COMMAND libbitcoin-node-test |
| 241 | + --run_test=* |
| 242 | + --show_progress=no |
| 243 | + --detect_memory_leak=0 |
| 244 | + --report_level=no |
| 245 | + --build_info=yes ) |
| 246 | + |
| 247 | +# libbitcoin-node-test project specific include directories. |
| 248 | +#------------------------------------------------------------------------------ |
| 249 | + target_include_directories( libbitcoin-node-test PRIVATE |
| 250 | + "../../include" ) |
| 251 | + |
| 252 | +# libbitcoin-node-test project specific libraries/linker flags. |
| 253 | +#------------------------------------------------------------------------------ |
| 254 | + target_link_libraries( libbitcoin-node-test |
| 255 | + ${CANONICAL_LIB_NAME} |
| 256 | + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ) |
| 257 | + |
| 258 | +endif() |
| 259 | + |
| 260 | +# Define bn project. |
| 261 | +#------------------------------------------------------------------------------ |
| 262 | +if (with-console) |
| 263 | + add_executable( bn |
| 264 | + "../../console/executor.cpp" |
| 265 | + "../../console/executor.hpp" |
| 266 | + "../../console/libbitcoin.ico" |
| 267 | + "../../console/main.cpp" ) |
| 268 | + |
| 269 | +# bn project specific include directories. |
| 270 | +#------------------------------------------------------------------------------ |
| 271 | + target_include_directories( bn PRIVATE |
| 272 | + "../../include" ) |
| 273 | + |
| 274 | +# bn project specific libraries/linker flags. |
| 275 | +#------------------------------------------------------------------------------ |
| 276 | + target_link_libraries( bn |
| 277 | + ${CANONICAL_LIB_NAME} ) |
| 278 | + |
| 279 | +endif() |
| 280 | + |
| 281 | +# Manage pkgconfig installation. |
| 282 | +#------------------------------------------------------------------------------ |
| 283 | +configure_file( |
| 284 | + "../../libbitcoin-node.pc.in" |
| 285 | + "libbitcoin-node.pc" @ONLY ) |
| 286 | + |
| 287 | +install( FILES |
| 288 | + "${CMAKE_CURRENT_BINARY_DIR}/libbitcoin-node.pc" |
| 289 | + DESTINATION "${pkgconfigdir}" ) |
| 290 | + |
| 291 | +# Manage installation of docs. |
| 292 | +#------------------------------------------------------------------------------ |
| 293 | +install( FILES |
| 294 | + "../../AUTHORS" |
| 295 | + "../../COPYING" |
| 296 | + "../../ChangeLog" |
| 297 | + "../../INSTALL" |
| 298 | + "../../NEWS" |
| 299 | + "../../README" |
| 300 | + DESTINATION share/doc/libbitcoin-node ) |
| 301 | + |
| 302 | +# Manage ${CANONICAL_LIB_NAME} installation. |
| 303 | +#------------------------------------------------------------------------------ |
| 304 | +install( TARGETS ${CANONICAL_LIB_NAME} |
| 305 | + RUNTIME DESTINATION bin |
| 306 | + LIBRARY DESTINATION lib |
| 307 | + ARCHIVE DESTINATION lib |
| 308 | + PUBLIC_HEADER DESTINATION include ) |
| 309 | + |
| 310 | +# Manage bn installation. |
| 311 | +#------------------------------------------------------------------------------ |
| 312 | +if (with-console) |
| 313 | + install( TARGETS bn |
| 314 | + RUNTIME DESTINATION bin |
| 315 | + LIBRARY DESTINATION lib |
| 316 | + ARCHIVE DESTINATION lib |
| 317 | + PUBLIC_HEADER DESTINATION include ) |
| 318 | +endif() |
| 319 | + |
| 320 | +# Manage include installation. |
| 321 | +#------------------------------------------------------------------------------ |
| 322 | +install( DIRECTORY "../../include/bitcoin" |
| 323 | + DESTINATION include ) |
| 324 | + |
| 325 | +# Manage data installation for bash_completion prefixed product. |
| 326 | +#------------------------------------------------------------------------------ |
| 327 | +if (bash-completiondir) |
| 328 | + install( FILES |
| 329 | + "../../data/bn" |
| 330 | + DESTINATION etc/libbitcoin ) |
| 331 | +endif() |
| 332 | + |
| 333 | +# Manage data installation for sysconf prefixed product. |
| 334 | +#------------------------------------------------------------------------------ |
| 335 | +if (with-console) |
| 336 | + install( FILES |
| 337 | + "../../data/bn.cfg" |
| 338 | + DESTINATION etc/libbitcoin ) |
| 339 | +endif() |
| 340 | + |
0 commit comments