|
| 1 | +############################################################################### |
| 2 | +# Copyright (c) 2014-2020 libbitcoin-server developers (see COPYING). |
| 3 | +# |
| 4 | +# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY |
| 5 | +# |
| 6 | +############################################################################### |
| 7 | + |
| 8 | +# libbitcoin-server project configuration. |
| 9 | +#------------------------------------------------------------------------------ |
| 10 | +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) |
| 11 | + |
| 12 | +project(libbitcoin-server 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-server ) |
| 24 | +else () |
| 25 | + set( CANONICAL_LIB_NAME bitcoin-server ) |
| 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-node |
| 121 | +#------------------------------------------------------------------------------ |
| 122 | +find_package( Bitcoin-Node 4.0.0 REQUIRED ) |
| 123 | + |
| 124 | +# Find bitcoin-protocol |
| 125 | +#------------------------------------------------------------------------------ |
| 126 | +find_package( Bitcoin-Protocol 4.0.0 REQUIRED ) |
| 127 | + |
| 128 | +# Define project common includes directories |
| 129 | +#------------------------------------------------------------------------------ |
| 130 | +if (BUILD_SHARED_LIBS) |
| 131 | + include_directories( SYSTEM |
| 132 | + ${bitcoin_protocol_INCLUDE_DIRS} |
| 133 | + ${bitcoin_node_INCLUDE_DIRS} ) |
| 134 | +else() |
| 135 | + include_directories( SYSTEM |
| 136 | + ${bitcoin_protocol_STATIC_INCLUDE_DIRS} |
| 137 | + ${bitcoin_node_STATIC_INCLUDE_DIRS} ) |
| 138 | +endif() |
| 139 | + |
| 140 | +# Define project common library directories |
| 141 | +#------------------------------------------------------------------------------ |
| 142 | +if (BUILD_SHARED_LIBS) |
| 143 | + link_directories( |
| 144 | + ${bitcoin_protocol_LIBRARY_DIRS} |
| 145 | + ${bitcoin_node_LIBRARY_DIRS} ) |
| 146 | +else() |
| 147 | + link_directories( |
| 148 | + ${bitcoin_protocol_STATIC_LIBRARY_DIRS} |
| 149 | + ${bitcoin_node_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_protocol_LIBRARIES} |
| 159 | + ${bitcoin_node_LIBRARIES} ) |
| 160 | +else() |
| 161 | + link_libraries( |
| 162 | + "-fstack-protector" |
| 163 | + "-fstack-protector-all" |
| 164 | + ${bitcoin_protocol_STATIC_LIBRARIES} |
| 165 | + ${bitcoin_node_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/parser.cpp" |
| 176 | + "../../src/server_node.cpp" |
| 177 | + "../../src/settings.cpp" |
| 178 | + "../../src/interface/blockchain.cpp" |
| 179 | + "../../src/interface/subscribe.cpp" |
| 180 | + "../../src/interface/transaction_pool.cpp" |
| 181 | + "../../src/interface/unsubscribe.cpp" |
| 182 | + "../../src/messages/message.cpp" |
| 183 | + "../../src/messages/route.cpp" |
| 184 | + "../../src/messages/subscription.cpp" |
| 185 | + "../../src/services/block_service.cpp" |
| 186 | + "../../src/services/heartbeat_service.cpp" |
| 187 | + "../../src/services/query_service.cpp" |
| 188 | + "../../src/services/transaction_service.cpp" |
| 189 | + "../../src/workers/authenticator.cpp" |
| 190 | + "../../src/workers/notification_worker.cpp" |
| 191 | + "../../src/workers/query_worker.cpp" ) |
| 192 | +
|
| 193 | +# ${CANONICAL_LIB_NAME} project specific include directories. |
| 194 | +#------------------------------------------------------------------------------ |
| 195 | +if (BUILD_SHARED_LIBS) |
| 196 | + target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE |
| 197 | + "../../include" |
| 198 | + ${bitcoin_protocol_INCLUDE_DIRS} |
| 199 | + ${bitcoin_node_INCLUDE_DIRS} ) |
| 200 | +else() |
| 201 | + target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE |
| 202 | + "../../include" |
| 203 | + ${bitcoin_protocol_STATIC_INCLUDE_DIRS} |
| 204 | + ${bitcoin_node_STATIC_INCLUDE_DIRS} ) |
| 205 | +endif() |
| 206 | +
|
| 207 | +target_include_directories( ${CANONICAL_LIB_NAME} PUBLIC |
| 208 | +"../../include" ) |
| 209 | +
|
| 210 | +# ${CANONICAL_LIB_NAME} project specific libraries/linker flags. |
| 211 | +#------------------------------------------------------------------------------ |
| 212 | +if (BUILD_SHARED_LIBS) |
| 213 | + target_link_libraries( ${CANONICAL_LIB_NAME} |
| 214 | + ${bitcoin_protocol_LIBRARIES} |
| 215 | + ${bitcoin_node_LIBRARIES} ) |
| 216 | +else() |
| 217 | + target_link_libraries( ${CANONICAL_LIB_NAME} |
| 218 | + ${bitcoin_protocol_STATIC_LIBRARIES} |
| 219 | + ${bitcoin_node_STATIC_LIBRARIES} ) |
| 220 | +endif() |
| 221 | +
|
| 222 | +# Define libbitcoin-server-test project. |
| 223 | +#------------------------------------------------------------------------------ |
| 224 | +if (with-tests) |
| 225 | + add_executable( libbitcoin-server-test |
| 226 | + "../../test/latest-addrs.py" |
| 227 | + "../../test/main.cpp" |
| 228 | + "../../test/popular_addrs.py" |
| 229 | + "../../test/server.cpp" |
| 230 | + "../../test/stress.sh" ) |
| 231 | +
|
| 232 | + add_test( NAME libbitcoin-server-test COMMAND libbitcoin-server-test |
| 233 | + --run_test=* |
| 234 | + --show_progress=no |
| 235 | + --detect_memory_leak=0 |
| 236 | + --report_level=no |
| 237 | + --build_info=yes ) |
| 238 | +
|
| 239 | +# libbitcoin-server-test project specific include directories. |
| 240 | +#------------------------------------------------------------------------------ |
| 241 | + target_include_directories( libbitcoin-server-test PRIVATE |
| 242 | + "../../include" ) |
| 243 | +
|
| 244 | +# libbitcoin-server-test project specific libraries/linker flags. |
| 245 | +#------------------------------------------------------------------------------ |
| 246 | + target_link_libraries( libbitcoin-server-test |
| 247 | + ${CANONICAL_LIB_NAME} |
| 248 | + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ) |
| 249 | +
|
| 250 | +endif() |
| 251 | +
|
| 252 | +# Define bs project. |
| 253 | +#------------------------------------------------------------------------------ |
| 254 | +if (with-console) |
| 255 | + add_executable( bs |
| 256 | + "../../console/executor.cpp" |
| 257 | + "../../console/executor.hpp" |
| 258 | + "../../console/libbitcoin.ico" |
| 259 | + "../../console/main.cpp" ) |
| 260 | +
|
| 261 | +# bs project specific include directories. |
| 262 | +#------------------------------------------------------------------------------ |
| 263 | + target_include_directories( bs PRIVATE |
| 264 | + "../../include" ) |
| 265 | +
|
| 266 | +# bs project specific libraries/linker flags. |
| 267 | +#------------------------------------------------------------------------------ |
| 268 | + target_link_libraries( bs |
| 269 | + ${CANONICAL_LIB_NAME} ) |
| 270 | +
|
| 271 | +endif() |
| 272 | +
|
| 273 | +# Manage pkgconfig installation. |
| 274 | +#------------------------------------------------------------------------------ |
| 275 | +configure_file( |
| 276 | + "../../libbitcoin-server.pc.in" |
| 277 | + "libbitcoin-server.pc" @ONLY ) |
| 278 | +
|
| 279 | +install( FILES |
| 280 | + "${CMAKE_CURRENT_BINARY_DIR}/libbitcoin-server.pc" |
| 281 | + DESTINATION "${pkgconfigdir}" ) |
| 282 | +
|
| 283 | +# Manage installation of docs. |
| 284 | +#------------------------------------------------------------------------------ |
| 285 | +install( FILES |
| 286 | + "../../AUTHORS" |
| 287 | + "../../COPYING" |
| 288 | + "../../ChangeLog" |
| 289 | + "../../INSTALL" |
| 290 | + "../../NEWS" |
| 291 | + "../../README" |
| 292 | + DESTINATION share/doc/libbitcoin-server ) |
| 293 | +
|
| 294 | +# Manage ${CANONICAL_LIB_NAME} installation. |
| 295 | +#------------------------------------------------------------------------------ |
| 296 | +install( TARGETS ${CANONICAL_LIB_NAME} |
| 297 | + RUNTIME DESTINATION bin |
| 298 | + LIBRARY DESTINATION lib |
| 299 | + ARCHIVE DESTINATION lib |
| 300 | + PUBLIC_HEADER DESTINATION include ) |
| 301 | +
|
| 302 | +# Manage bs installation. |
| 303 | +#------------------------------------------------------------------------------ |
| 304 | +if (with-console) |
| 305 | + install( TARGETS bs |
| 306 | + RUNTIME DESTINATION bin |
| 307 | + LIBRARY DESTINATION lib |
| 308 | + ARCHIVE DESTINATION lib |
| 309 | + PUBLIC_HEADER DESTINATION include ) |
| 310 | +endif() |
| 311 | +
|
| 312 | +# Manage include installation. |
| 313 | +#------------------------------------------------------------------------------ |
| 314 | +install( DIRECTORY "../../include/bitcoin" |
| 315 | + DESTINATION include ) |
| 316 | +
|
| 317 | +# Manage data installation for bash_completion prefixed product. |
| 318 | +#------------------------------------------------------------------------------ |
| 319 | +if (bash-completiondir) |
| 320 | + install( FILES |
| 321 | + "../../data/bs" |
| 322 | + DESTINATION etc/libbitcoin ) |
| 323 | +endif() |
| 324 | +
|
| 325 | +# Manage data installation for sysconf prefixed product. |
| 326 | +#------------------------------------------------------------------------------ |
| 327 | +install( FILES |
| 328 | + "../../data/bs.cfg" |
| 329 | + DESTINATION etc/libbitcoin ) |
| 330 | +
|
0 commit comments