|
| 1 | +############################################################################### |
| 2 | +# Copyright (c) 2014-2018 libbitcoin-protocol developers (see COPYING). |
| 3 | +# |
| 4 | +# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY |
| 5 | +# |
| 6 | +############################################################################### |
| 7 | + |
| 8 | +# libbitcoin-protocol project configuration. |
| 9 | +#------------------------------------------------------------------------------ |
| 10 | +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) |
| 11 | + |
| 12 | +project(libbitcoin-protocol 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-protocol ) |
| 24 | +else () |
| 25 | + set( CANONICAL_LIB_NAME bitcoin-protocol ) |
| 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 all stuff. |
| 46 | +add_compile_options( "-Wall" ) |
| 47 | + |
| 48 | +# Warn on extra stuff. |
| 49 | +add_compile_options( "-Wextra" ) |
| 50 | + |
| 51 | +# Warn on extra stuff. |
| 52 | +add_compile_options( "-Wextra" ) |
| 53 | + |
| 54 | +# Be really annoying. |
| 55 | +add_compile_options( "-Wpedantic" ) |
| 56 | + |
| 57 | +# Be really annoying. |
| 58 | +add_compile_options( "-Wpedantic" ) |
| 59 | + |
| 60 | +# Disallow warning on style order of declarations. |
| 61 | +add_compile_options( "-Wno-reorder" ) |
| 62 | + |
| 63 | +# Suppress warning for incomplete field initialization. |
| 64 | +add_compile_options( "-Wno-missing-field-initializers" ) |
| 65 | + |
| 66 | +# Conform to style. |
| 67 | +add_compile_options( "-Wno-missing-braces" ) |
| 68 | + |
| 69 | +# Ignore comments within comments or commenting of backslash extended lines. |
| 70 | +add_compile_options( "-Wno-comment" ) |
| 71 | + |
| 72 | +# Conflict in stdlib under clang. |
| 73 | +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") |
| 74 | + add_compile_options( "-Wno-mismatched-tags" ) |
| 75 | +endif() |
| 76 | + |
| 77 | +# Implement -Dpkgconfigdir and output ${pkgconfigdir}. |
| 78 | +#------------------------------------------------------------------------------ |
| 79 | +set( pkgconfigdir "${libdir}/pkgconfig" CACHE PATH "Path to pkgconfig directory." ) |
| 80 | + |
| 81 | +# Implement -Dwith-tests and declare with-tests. |
| 82 | +#------------------------------------------------------------------------------ |
| 83 | +set( with-tests "yes" CACHE BOOL "Compile with unit tests." ) |
| 84 | + |
| 85 | +# Implement -Denable-ndebug and define NDEBUG. |
| 86 | +#------------------------------------------------------------------------------ |
| 87 | +set( enable-ndebug "yes" CACHE BOOL "Compile without debug assertions." ) |
| 88 | + |
| 89 | +if (enable-ndebug) |
| 90 | + add_definitions( -DNDEBUG ) |
| 91 | +endif() |
| 92 | + |
| 93 | +# Inherit -Denable-shared and define BOOST_ALL_DYN_LINK. |
| 94 | +#------------------------------------------------------------------------------ |
| 95 | +if (BUILD_SHARED_LIBS) |
| 96 | + add_definitions( -DBOOST_ALL_DYN_LINK ) |
| 97 | +endif() |
| 98 | + |
| 99 | +# Find boost |
| 100 | +#------------------------------------------------------------------------------ |
| 101 | +find_package( Boost 1.62.0 REQUIRED COMPONENTS |
| 102 | + unit_test_framework ) |
| 103 | + |
| 104 | +set( boost_unit_test_framework_LIBS "-lboost_unit_test_framework" ) |
| 105 | + |
| 106 | +if (enable-ndebug) |
| 107 | + set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_DEBUG}" ) |
| 108 | +else () |
| 109 | + set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_RELEASE}" ) |
| 110 | +endif() |
| 111 | + |
| 112 | +set( boost_CPPFLAGS "-I${Boost_INCLUDE_DIR}" ) |
| 113 | +set( boost_LDFLAGS "-L${Boost_LIBRARY_DIR}" ) |
| 114 | + |
| 115 | +# Find zmq |
| 116 | +#------------------------------------------------------------------------------ |
| 117 | +find_package( Zmq 4.2.5 REQUIRED ) |
| 118 | + |
| 119 | +# Find bitcoin |
| 120 | +#------------------------------------------------------------------------------ |
| 121 | +find_package( Bitcoin 4.0.0 REQUIRED ) |
| 122 | + |
| 123 | +# Define project common includes directories |
| 124 | +#------------------------------------------------------------------------------ |
| 125 | +if (BUILD_SHARED_LIBS) |
| 126 | + include_directories( SYSTEM |
| 127 | + ${zmq_INCLUDE_DIRS} |
| 128 | + ${bitcoin_INCLUDE_DIRS} ) |
| 129 | +else() |
| 130 | + include_directories( SYSTEM |
| 131 | + ${zmq_STATIC_INCLUDE_DIRS} |
| 132 | + ${bitcoin_STATIC_INCLUDE_DIRS} ) |
| 133 | +endif() |
| 134 | + |
| 135 | +# Define project common library directories |
| 136 | +#------------------------------------------------------------------------------ |
| 137 | +if (BUILD_SHARED_LIBS) |
| 138 | + link_directories( |
| 139 | + ${zmq_LIBRARY_DIRS} |
| 140 | + ${bitcoin_LIBRARY_DIRS} ) |
| 141 | +else() |
| 142 | + link_directories( |
| 143 | + ${zmq_STATIC_LIBRARY_DIRS} |
| 144 | + ${bitcoin_STATIC_LIBRARY_DIRS} ) |
| 145 | +endif() |
| 146 | + |
| 147 | +# Define project common libraries/linker flags. |
| 148 | +#------------------------------------------------------------------------------ |
| 149 | +if (BUILD_SHARED_LIBS) |
| 150 | + link_libraries( |
| 151 | + "-fstack-protector" |
| 152 | + "-fstack-protector-all" |
| 153 | + ${zmq_LIBRARIES} |
| 154 | + ${bitcoin_LIBRARIES} ) |
| 155 | +else() |
| 156 | + link_libraries( |
| 157 | + "-fstack-protector" |
| 158 | + "-fstack-protector-all" |
| 159 | + ${zmq_STATIC_LIBRARIES} |
| 160 | + ${bitcoin_STATIC_LIBRARIES} ) |
| 161 | +endif() |
| 162 | + |
| 163 | +# Define ${CANONICAL_LIB_NAME} project. |
| 164 | +#------------------------------------------------------------------------------ |
| 165 | +add_library( ${CANONICAL_LIB_NAME} |
| 166 | + "../../src/settings.cpp" |
| 167 | + "../../src/zmq/authenticator.cpp" |
| 168 | + "../../src/zmq/certificate.cpp" |
| 169 | + "../../src/zmq/context.cpp" |
| 170 | + "../../src/zmq/frame.cpp" |
| 171 | + "../../src/zmq/identifiers.cpp" |
| 172 | + "../../src/zmq/message.cpp" |
| 173 | + "../../src/zmq/poller.cpp" |
| 174 | + "../../src/zmq/socket.cpp" |
| 175 | + "../../src/zmq/worker.cpp" |
| 176 | + "../../src/zmq/zeromq.cpp" ) |
| 177 | + |
| 178 | +# ${CANONICAL_LIB_NAME} project specific include directories. |
| 179 | +#------------------------------------------------------------------------------ |
| 180 | +if (BUILD_SHARED_LIBS) |
| 181 | + target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE |
| 182 | + "../../include" |
| 183 | + ${zmq_INCLUDE_DIRS} |
| 184 | + ${bitcoin_INCLUDE_DIRS} ) |
| 185 | +else() |
| 186 | + target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE |
| 187 | + "../../include" |
| 188 | + ${zmq_STATIC_INCLUDE_DIRS} |
| 189 | + ${bitcoin_STATIC_INCLUDE_DIRS} ) |
| 190 | +endif() |
| 191 | + |
| 192 | +target_include_directories( ${CANONICAL_LIB_NAME} PUBLIC |
| 193 | +"../../include" ) |
| 194 | + |
| 195 | +# ${CANONICAL_LIB_NAME} project specific libraries/linker flags. |
| 196 | +#------------------------------------------------------------------------------ |
| 197 | +if (BUILD_SHARED_LIBS) |
| 198 | + target_link_libraries( ${CANONICAL_LIB_NAME} |
| 199 | + ${zmq_LIBRARIES} |
| 200 | + ${bitcoin_LIBRARIES} ) |
| 201 | +else() |
| 202 | + target_link_libraries( ${CANONICAL_LIB_NAME} |
| 203 | + ${zmq_STATIC_LIBRARIES} |
| 204 | + ${bitcoin_STATIC_LIBRARIES} ) |
| 205 | +endif() |
| 206 | + |
| 207 | +# Define libbitcoin-protocol-test project. |
| 208 | +#------------------------------------------------------------------------------ |
| 209 | +if (with-tests) |
| 210 | + add_executable( libbitcoin-protocol-test |
| 211 | + "../../test/converter.cpp" |
| 212 | + "../../test/main.cpp" |
| 213 | + "../../test/utility.hpp" |
| 214 | + "../../test/zmq/authenticator.cpp" |
| 215 | + "../../test/zmq/certificate.cpp" |
| 216 | + "../../test/zmq/context.cpp" |
| 217 | + "../../test/zmq/frame.cpp" |
| 218 | + "../../test/zmq/identifiers.cpp" |
| 219 | + "../../test/zmq/message.cpp" |
| 220 | + "../../test/zmq/poller.cpp" |
| 221 | + "../../test/zmq/socket.cpp" |
| 222 | + "../../test/zmq/worker.cpp" ) |
| 223 | + |
| 224 | + add_test( NAME libbitcoin-protocol-test COMMAND libbitcoin-protocol-test |
| 225 | + --run_test=* |
| 226 | + --show_progress=no |
| 227 | + --detect_memory_leak=0 |
| 228 | + --report_level=no |
| 229 | + --build_info=yes ) |
| 230 | + |
| 231 | +# libbitcoin-protocol-test project specific include directories. |
| 232 | +#------------------------------------------------------------------------------ |
| 233 | + target_include_directories( libbitcoin-protocol-test PRIVATE |
| 234 | + "../../include" ) |
| 235 | + |
| 236 | +# libbitcoin-protocol-test project specific libraries/linker flags. |
| 237 | +#------------------------------------------------------------------------------ |
| 238 | + target_link_libraries( libbitcoin-protocol-test |
| 239 | + ${CANONICAL_LIB_NAME} |
| 240 | + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ) |
| 241 | + |
| 242 | +endif() |
| 243 | + |
| 244 | +# Manage pkgconfig installation. |
| 245 | +#------------------------------------------------------------------------------ |
| 246 | +configure_file( |
| 247 | + "../../libbitcoin-protocol.pc.in" |
| 248 | + "libbitcoin-protocol.pc" @ONLY ) |
| 249 | + |
| 250 | +install( FILES |
| 251 | + "${CMAKE_CURRENT_BINARY_DIR}/libbitcoin-protocol.pc" |
| 252 | + DESTINATION "${pkgconfigdir}" ) |
| 253 | + |
| 254 | +# Manage installation of docs. |
| 255 | +#------------------------------------------------------------------------------ |
| 256 | +install( FILES |
| 257 | + "../../AUTHORS" |
| 258 | + "../../COPYING" |
| 259 | + "../../ChangeLog" |
| 260 | + "../../INSTALL" |
| 261 | + "../../NEWS" |
| 262 | + "../../README" |
| 263 | + DESTINATION share/doc/libbitcoin-protocol ) |
| 264 | + |
| 265 | +# Manage ${CANONICAL_LIB_NAME} installation. |
| 266 | +#------------------------------------------------------------------------------ |
| 267 | +install( TARGETS ${CANONICAL_LIB_NAME} |
| 268 | + RUNTIME DESTINATION bin |
| 269 | + LIBRARY DESTINATION lib |
| 270 | + ARCHIVE DESTINATION lib |
| 271 | + PUBLIC_HEADER DESTINATION include ) |
| 272 | + |
| 273 | +# Manage include installation. |
| 274 | +#------------------------------------------------------------------------------ |
| 275 | +install( DIRECTORY "../../include/bitcoin" |
| 276 | + DESTINATION include ) |
| 277 | + |
0 commit comments