forked from libbitcoin/libbitcoin-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
727 lines (591 loc) · 24.6 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
#
# Copyright (c) 2017 Bitprim developers (see AUTHORS)
#
# This file is part of Bitprim.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.4)
# bitprim-blockchain
#==============================================================================
project(bitprim-blockchain
VERSION 0
LANGUAGES CXX C)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Check for baseline language coverage in the compiler for the C++14 standard.
#------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Process options.
#==============================================================================
# Implement --use-conan
#------------------------------------------------------------------------------
option(USE_CONAN "Use Conan Build Tool." OFF)
option(NO_CONAN_AT_ALL "Conan totally disabled." OFF)
if (NO_CONAN_AT_ALL)
set(USE_CONAN OFF)
endif()
# Inherit --enable-shared and define BOOST_TEST_DYN_LINK.
#------------------------------------------------------------------------------
option(ENABLE_SHARED "" OFF)
# Implement POSITION_INDEPENDENT_CODE
#------------------------------------------------------------------------------
option(ENABLE_POSITION_INDEPENDENT_CODE "Enable POSITION_INDEPENDENT_CODE property" ON)
# Implement --with-consensus and define WITH_CONSENSUS.
#------------------------------------------------------------------------------
option(WITH_CONSENSUS "Link bitprim-consensus and use for consensus checks." ON)
# Implement --with-tests and declare WITH_TESTS.
#------------------------------------------------------------------------------
option(WITH_TESTS "Compile with unit tests." ON)
option(WITH_TESTS_NEW "Compile with unit tests." OFF)
# Implement --with-tools and declare WITH_TOOLS.
#------------------------------------------------------------------------------
option(WITH_TOOLS "Compile with tools." OFF)
# Implement --with-keoken and declare WITH_KEOKEN.
#------------------------------------------------------------------------------
option(WITH_KEOKEN "Keoken enabled." OFF)
if (WITH_KEOKEN)
message(STATUS "Bitprim: Keoken enabled")
add_definitions(-DBITPRIM_WITH_KEOKEN)
endif()
# # Implement --with-mining and declare WITH_MINING.
# #------------------------------------------------------------------------------
# option(WITH_MINING "Mining enabled." OFF)
# if (WITH_MINING)
# message(STATUS "Bitprim: Mining enabled")
# add_definitions(-DBITPRIM_WITH_MINING)
# endif()
# Implement --with-mempool and declare WITH_MEMPOOL.
#------------------------------------------------------------------------------
option(WITH_MEMPOOL "Mempool enabled." OFF)
if (WITH_MEMPOOL)
message(STATUS "Bitprim: Mempool enabled")
add_definitions(-DBITPRIM_WITH_MEMPOOL)
endif()
# Implement --use-domain and declare USE_DOMAIN.
#------------------------------------------------------------------------------
option(USE_DOMAIN "Domain enabled." ON)
if (USE_DOMAIN)
message(STATUS "Bitprim: Using Domain enabled")
add_definitions(-DBITPRIM_USE_DOMAIN)
endif()
# Implement and declare DB_TRANSACTION_UNCONFIRMED.
#------------------------------------------------------------------------------
option(DB_TRANSACTION_UNCONFIRMED "DB Transactions Unconfirmed enabled." ON)
if (DB_TRANSACTION_UNCONFIRMED)
message(STATUS "Bitprim: DB Transactions Unconfirmed enabled")
add_definitions(-DBITPRIM_DB_TRANSACTION_UNCONFIRMED)
endif()
# Implement and declare DB_SPENDS.
#------------------------------------------------------------------------------
option(DB_SPENDS "DB Spends enabled." ON)
if (DB_SPENDS)
message(STATUS "Bitprim: DB Spends enabled")
add_definitions(-DBITPRIM_DB_SPENDS)
endif()
# Implement and declare DB_HISTORY.
#------------------------------------------------------------------------------
option(DB_HISTORY "DB History enabled." ON)
if (DB_HISTORY)
message(STATUS "Bitprim: DB History enabled")
add_definitions(-DBITPRIM_DB_HISTORY)
endif()
# Implement and declare DB_STEALTH.
#------------------------------------------------------------------------------
option(DB_STEALTH "DB Stealth enabled." ON)
if (DB_STEALTH)
message(STATUS "Bitprim: DB Stealth enabled")
add_definitions(-DBITPRIM_DB_STEALTH)
endif()
# Implement and declare DB_UNSPENT_LIBBITCOIN.
#------------------------------------------------------------------------------
option(DB_UNSPENT_LIBBITCOIN "DB Unspent Libbitcoin enabled." ON)
if (DB_UNSPENT_LIBBITCOIN)
message(STATUS "Bitprim: DB Unspent Libbitcoin enabled")
add_definitions(-DBITPRIM_DB_UNSPENT_LIBBITCOIN)
endif()
# Implement and declare DB_LEGACY.
#------------------------------------------------------------------------------
option(DB_LEGACY "DB Legacy enabled." ON)
if (DB_LEGACY)
message(STATUS "Bitprim: DB Legacy enabled")
add_definitions(-DBITPRIM_DB_LEGACY)
endif()
# Implement and declare DB_NEW.
#------------------------------------------------------------------------------
option(DB_NEW "DB New enabled." OFF)
if (DB_NEW)
message(STATUS "Bitprim: DB New enabled")
add_definitions(-DBITPRIM_DB_NEW)
endif()
# Implement and declare DB_NEW_BLOCKS.
#------------------------------------------------------------------------------
option(DB_NEW_BLOCKS "DB Blocks New enabled." OFF)
if (DB_NEW_BLOCKS)
message(STATUS "Bitprim: DB Blocks New enabled")
add_definitions(-DBITPRIM_DB_NEW_BLOCKS)
endif()
# Implement and declare DB_NEW_FULL.
#------------------------------------------------------------------------------
option(DB_NEW_FULL "DB New Full enabled." OFF)
if (DB_NEW_FULL)
message(STATUS "Bitprim: DB New Full enabled")
add_definitions(-DBITPRIM_DB_NEW_FULL)
endif()
# Implement --JUST_BITPRIM_SOURCES for linting.
#------------------------------------------------------------------------------
option(JUST_BITPRIM_SOURCES "Just Bitprim source code to be linted." OFF)
if (JUST_BITPRIM_SOURCES)
message(STATUS "Bitprim: Just Bitprim source code to be linted: enabled")
endif()
set(BITPRIM_PROJECT_VERSION "-" CACHE STRING "Specify the Bitprim Project Version.")
# message(${BITPRIM_PROJECT_VERSION})
set(MICROARCHITECTURE "x86_64" CACHE STRING "Specify the Cryptocurrency (x86_64|...).")
message( STATUS "Bitprim: Compiling for ${MICROARCHITECTURE}")
# add_definitions(-DBITPRIM_MICROARCHITECTURE=${MICROARCHITECTURE})
# add_definitions(-DBITPRIM_MICROARCHITECTURE_STR="${MICROARCHITECTURE}")
set(CURRENCY "BCH" CACHE STRING "Specify the Cryptocurrency (BCH|BTC|LTC).")
if (${CURRENCY} STREQUAL "BCH")
add_definitions(-DBITPRIM_CURRENCY_BCH)
elseif (${CURRENCY} STREQUAL "BTC")
add_definitions(-DBITPRIM_CURRENCY_BTC)
elseif (${CURRENCY} STREQUAL "LTC")
add_definitions(-DBITPRIM_CURRENCY_LTC)
else()
message(FATAL_ERROR "Invalid Cryptocurrency: ${CURRENCY}")
endif()
message(STATUS "Bitprim: Cryptocurrency: ${CURRENCY}")
# Implement --with-remote-database and declare WITH_REMOTE_DATABASE.
#------------------------------------------------------------------------------
option(WITH_REMOTE_DATABASE "Compile with remote bitprim-database (aka. bitprim-database-requester)." OFF)
# Conan infrastructure.
#==============================================================================
if(EXISTS ${CMAKE_SOURCE_DIR}/ci_utils/cmake/bitprimbuildinfo.cmake)
include(${CMAKE_SOURCE_DIR}/ci_utils/cmake/bitprimbuildinfo.cmake)
else()
message( STATUS "bitprimbuildinfo doent exists")
endif()
# Check dependencies.
#==============================================================================
#------------------------------------------------------------------------------
if (NO_CONAN_AT_ALL)
# Require Boost of at least version 1.56.0 and output ${boost_CPPFLAGS/LDFLAGS}.
#------------------------------------------------------------------------------
if (NOT ENABLE_SHARED)
set(Boost_USE_STATIC_LIBS ON)
endif()
if (MSVC)
find_package(
Boost 1.56.0 REQUIRED
COMPONENTS atomic chrono date_time filesystem iostreams locale log log_setup program_options regex system thread unit_test_framework
)
else()
find_package(
Boost 1.56.0 REQUIRED
COMPONENTS chrono date_time filesystem iostreams locale log program_options regex system thread unit_test_framework
)
endif()
endif()
if (NOT USE_CONAN)
# Require bitprim-database (or bitprim-database-requester) of at least version 0 and output ${bitprim_database_CPPFLAGS/LIBS/PKG}.
#------------------------------------------------------------------------------
if (WITH_REMOTE_DATABASE)
if (NOT TARGET bitprim-database-requester)
find_package(bitprim-database-requester 0 REQUIRED)
endif()
else()
if (NOT TARGET bitprim-database)
find_package(bitprim-database 0 REQUIRED)
endif()
endif()
# Require bitprim-consensus of at least version 0 and output ${bitprim_consensus_CPPFLAGS/LIBS/PKG}.
#------------------------------------------------------------------------------
if (WITH_CONSENSUS)
if (NOT TARGET bitprim-consensus)
find_package(bitprim-consensus 0 REQUIRED)
endif()
endif()
endif(NOT USE_CONAN)
# Set flags.
#==============================================================================
include(CheckCXXCompilerFlag)
# Including common functions
#------------------------------------------------------------------------------
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/ci_utils/cmake)
include(BitprimTools)
# Warn on all stuff.
#------------------------------------------------------------------------------
if (NOT MSVC)
_add_c_compile_flag(-Wall _has_all_warning_flag)
else()
_add_c_compile_flag(-W4 _has_all_warning_flag)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
# Warn on extra stuff.
#------------------------------------------------------------------------------
if (NOT MSVC)
_add_c_compile_flag(-Wextra _has_extra_warning_flag)
endif()
# Be really annoying.
#------------------------------------------------------------------------------
_add_c_compile_flag(-Wpedantic _has_pedantic_warning_flag)
if (_has_pedantic_warning_flag)
_add_c_compile_flag(-pedantic _has_pedantic_flag)
endif()
# Conform to style.
#------------------------------------------------------------------------------
_add_cxx_compile_flag(-Wno-missing-braces _has_no_missing_braces_warning_flag)
# Conflict in stdlib under clang. Enabled in clang only.
#------------------------------------------------------------------------------
_add_cxx_compile_flag(-Wno-mismatched-tags _has_no_mismatched_tags_warning_flag)
# Clean up boost 1.55 headers. Enabled in gcc only.
#------------------------------------------------------------------------------
_add_c_compile_flag(-Wno-deprecated-declarations _has_no_deprecated_declarations_warning_flag)
# Protect stack.
#------------------------------------------------------------------------------
_add_link_flag(-fstack-protector _has_stack_protector_flag)
# Protect stack comprehensively.
#------------------------------------------------------------------------------
_add_link_flag(-fstack-protector-all _has_stack_protector_all_flag)
# Hide internal functions from external libs. Enabled in gcc only.
#------------------------------------------------------------------------------
_add_cxx_compile_flag(-fvisibility-hidden _has_visibility_hidden_flag)
# Hide inlines from external libs. Enabled in gcc only.
#------------------------------------------------------------------------------
_add_cxx_compile_flag(-fvisibility-inlines-hidden _has_visibility_inlines_hidden_flag)
# Target Windows Vista. Enabled in msvc only.
#------------------------------------------------------------------------------
if (MSVC) # OR MINGW)
add_definitions(-D_WIN32_WINNT=0x0600)
endif()
# Build
#==============================================================================
# src/bitprim-blockchain.la => ${libdir}
#------------------------------------------------------------------------------
set(MODE STATIC)
if (ENABLE_SHARED)
set(MODE SHARED)
endif()
set(bitprim_blockchain_sources_just_libbitcoin
src/interface/block_chain.cpp
src/pools/block_entry.cpp
src/pools/block_organizer.cpp
src/pools/block_pool.cpp
src/pools/branch.cpp
src/pools/transaction_entry.cpp
src/pools/transaction_organizer.cpp
src/pools/transaction_pool.cpp
src/pools/mempool_transaction_summary.cpp #Rama
src/populate/populate_base.cpp
src/populate/populate_block.cpp
src/populate/populate_chain_state.cpp
src/populate/populate_transaction.cpp
src/validate/validate_block.cpp
src/validate/validate_input.cpp
src/validate/validate_transaction.cpp
src/settings.cpp
src/version.cpp
src/bitprim/interface/block_chain.cpp
)
set(bitprim_blockchain_sources_just_bitprim
src/bitprim/interface/block_chain.cpp
)
# message(STATUS "TODO(fernando) WITH_KEOKEN: ${WITH_KEOKEN}")
if (WITH_KEOKEN)
set(bitprim_blockchain_sources_just_bitprim
${bitprim_blockchain_sources_just_bitprim}
src/bitprim/keoken/memory_state.cpp
)
endif()
if (NOT JUST_BITPRIM_SOURCES)
set(bitprim_blockchain_sources
${bitprim_blockchain_sources_just_libbitcoin}
)
endif()
set(bitprim_blockchain_sources
${bitprim_blockchain_sources}
${bitprim_blockchain_sources_just_bitprim}
)
add_library(bitprim-blockchain ${MODE} ${bitprim_blockchain_sources})
if (ENABLE_POSITION_INDEPENDENT_CODE)
set_property(TARGET bitprim-blockchain PROPERTY POSITION_INDEPENDENT_CODE ON)
endif(ENABLE_POSITION_INDEPENDENT_CODE)
target_include_directories(bitprim-blockchain PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_definitions(bitprim-blockchain PUBLIC -DBITPRIM_PROJECT_VERSION="\\"${BITPRIM_PROJECT_VERSION}\\"") #TODO(fernando): manage with Conan????
if (NOT ENABLE_SHARED)
target_compile_definitions(bitprim-blockchain PUBLIC -DBCB_STATIC -DBCD_STATIC -DBC_STATIC)
endif()
if (WITH_CONSENSUS)
target_compile_definitions(bitprim-blockchain PUBLIC -DBCK_STATIC) #TODO(fernando): por que esta afuera?
endif(WITH_CONSENSUS)
if (WITH_REMOTE_DATABASE)
if (NOT USE_CONAN)
target_link_libraries(bitprim-blockchain bitprim-database-requester)
endif(NOT USE_CONAN)
target_compile_definitions(bitprim-blockchain PUBLIC -DWITH_REMOTE_DATABASE)
else()
if (NOT USE_CONAN)
target_link_libraries(bitprim-blockchain PUBLIC bitprim-database)
endif(NOT USE_CONAN)
endif()
# #TODO(fernando): See what to do with this option. Move to Conan?
# if (NOT NO_CONAN_AT_ALL)
# if (WITH_CONSENSUS)
# target_compile_definitions(bitprim-blockchain PUBLIC -DWITH_CONSENSUS)
# target_link_libraries(bitprim-blockchain PUBLIC ${CONAN_LIBS})
# else()
# target_link_libraries(bitprim-blockchain PUBLIC ${CONAN_LIBS})
# endif()
# else()
# if (WITH_CONSENSUS)
# target_link_libraries(bitprim-blockchain bitprim-consensus -DWITH_CONSENSUS)
# else()
# target_link_libraries(bitprim-blockchain bitprim-consensus)
# endif()
# endif()
if (WITH_CONSENSUS)
target_compile_definitions(bitprim-blockchain PUBLIC -DWITH_CONSENSUS)
if (NOT USE_CONAN)
target_link_libraries(bitprim-blockchain PUBLIC bitprim-consensus)
endif(NOT USE_CONAN)
endif(WITH_CONSENSUS)
if (NOT NO_CONAN_AT_ALL) # at least with external libraries
target_link_libraries(bitprim-blockchain PUBLIC ${CONAN_LIBS})
endif()
# if (USE_CONAN)
if (MINGW)
target_link_libraries(bitprim-blockchain PUBLIC ws2_32 wsock32) #TODO(fernando): manage with Conan
endif()
# endif()
_group_sources(bitprim-blockchain "${CMAKE_CURRENT_LIST_DIR}")
# # src/bitprim-blockchain-replier => ${bindir}
# #------------------------------------------------------------------------------
# add_executable(bitprim-blockchain-replier
# replier/src/blockchain.cpp
# replier/src/configuration.cpp
# replier/src/main.cpp
# replier/src/parser.cpp)
# if (NOT MSVC)
# target_compile_definitions(bitprim-blockchain-replier PUBLIC -DSYSCONFDIR=\"${SYSCONFDIR}\")
# endif()
# target_link_libraries(bitprim-blockchain-replier bitprim-network bitprim-protocol bitprim-blockchain)
# target_include_directories(bitprim-blockchain-replier PRIVATE
# ${CMAKE_CURRENT_SOURCE_DIR}/replier/include)
# _group_sources(bitprim-blockchain-replier "${CMAKE_CURRENT_LIST_DIR}/replier")
# # src/bitprim-blockchain-requester.la => ${libdir}
# #------------------------------------------------------------------------------
# add_library(bitprim-blockchain-requester ${MODE}
# requester/src/block_chain.cpp
# src/interface/block_fetcher.cpp
# src/pools/orphan_pool.cpp
# src/pools/orphan_pool_manager.cpp
# src/pools/transaction_pool.cpp
# src/pools/transaction_pool_index.cpp
# src/settings.cpp
# src/validation/fork.cpp
# src/validation/populate_block.cpp
# src/validation/validate_block.cpp
# src/validation/validate_input.cpp)
# target_include_directories(bitprim-blockchain-requester PUBLIC
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
# $<INSTALL_INTERFACE:include>)
#
# target_compile_definitions(bitprim-blockchain-requester PUBLIC -DBCB_STATIC)
# target_include_directories(bitprim-blockchain-requester PRIVATE
# ${CMAKE_CURRENT_SOURCE_DIR}/src/clone)
# target_compile_definitions(bitprim-blockchain-requester PUBLIC
# -DWITH_BLOCKCHAIN_REQUESTER)
# add_dependencies(bitprim-blockchain-requester bitprim-blockchain-replier)
#
# target_link_libraries(bitprim-blockchain-requester bitprim-database bitprim-protocol)
# if (WITH_CONSENSUS)
# target_link_libraries(bitprim-blockchain-requester bitprim-consensus-requester)
# endif()
# _group_sources(bitprim-blockchain-requester "${CMAKE_CURRENT_LIST_DIR}/requester")
# Tests
#==============================================================================
if (WITH_TESTS OR WITH_TESTS_NEW)
enable_testing()
endif()
# local: test/bitprim_blockchain_test
#------------------------------------------------------------------------------
if (WITH_TESTS)
add_executable(bitprim_blockchain_test
test/block_chain.cpp
test/block_entry.cpp
test/block_pool.cpp
test/branch.cpp
test/transaction_entry.cpp
test/transaction_pool.cpp
test/validate_block.cpp
test/validate_transaction.cpp
test/utxo.cpp
test/main.cpp
)
target_link_libraries(bitprim_blockchain_test PUBLIC bitprim-blockchain)
_group_sources(bitprim_blockchain_test "${CMAKE_CURRENT_LIST_DIR}/test")
# _add_tests(bitprim_blockchain_test "blockchain" transaction_pool_tests) # validate_block_tests) # no test cases
_add_tests(bitprim_blockchain_test
block_entry_tests
block_pool_tests
branch_tests
transaction_entry_tests
validate_block_tests
validate_transaction_tests
)
if (DB_LEGACY)
_add_tests(bitprim_blockchain_test
fast_chain_tests
safe_chain_tests
)
endif()
if (DB_NEW)
if (NOT WIN32)
_add_tests(bitprim_blockchain_test
utxo_tests
)
endif()
endif()
endif()
if (WITH_TESTS_NEW)
if (WITH_MEMPOOL OR WITH_KEOKEN)
set(bitprim_blockchain_test_new_sources
test_new/main.cpp
)
if (WITH_MEMPOOL)
set(bitprim_blockchain_test_new_sources
${bitprim_blockchain_test_new_sources}
test_new/mempool_tests.cpp
)
endif()
if (WITH_KEOKEN)
set(bitprim_blockchain_test_new_sources
${bitprim_blockchain_test_new_sources}
test_new/state_delegated_tests.cpp
test_new/state_tests.cpp
test_new/interpreter_tests.cpp
)
endif()
add_executable(bitprim_blockchain_test_new
${bitprim_blockchain_test_new_sources}
)
target_link_libraries(bitprim_blockchain_test_new PUBLIC bitprim-blockchain)
add_test(NAME bitprim_blockchain_test_new COMMAND bitprim_blockchain_test_new)
endif()
endif()
# # local: test/bitprim_blockchain_requester_test
# #------------------------------------------------------------------------------
# if (WITH_TESTS)
# add_executable(bitprim_blockchain_requester_test
# test/main.cpp
# test/transaction_pool.cpp
# test/validate_block.cpp)
# target_compile_definitions(bitprim_blockchain_requester_test PRIVATE
# -DWITH_BLOCKCHAIN_REPLIER="$<TARGET_FILE:bitprim-blockchain-replier>")
# target_include_directories(bitprim_blockchain_requester_test PRIVATE
# ${CMAKE_CURRENT_SOURCE_DIR}/requester/test)
# target_link_libraries(bitprim_blockchain_requester_test PUBLIC bitprim-blockchain-requester)
# if (WITH_CONSENSUS)
# target_compile_definitions(bitprim_blockchain_requester_test PRIVATE
# -DWITH_CONSENSUS_REPLIER="$<TARGET_FILE:bitprim-consensus-replier>")
# endif()
# _add_tests(bitprim_blockchain_requester_test "blockchain-requester"
# transaction_pool_tests)
# # validate_block_tests) # no test cases
# _group_sources(bitprim_blockchain_requester_test "${CMAKE_CURRENT_LIST_DIR}/test")
# endif()
# Tools
#==============================================================================
# local: tools/initchain/initchain
#------------------------------------------------------------------------------
if (WITH_TOOLS)
add_executable(tools.initchain tools/initchain/initchain.cpp)
target_link_libraries(tools.initchain bitprim-blockchain)
_group_sources(tools.initchain "${CMAKE_CURRENT_LIST_DIR}/tools/initchain")
endif()
# Install
#==============================================================================
# install(TARGETS bitprim-blockchain bitprim-blockchain-requester bitprim-blockchain-replier
install(TARGETS bitprim-blockchain EXPORT bitprim-blockchain
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
set(_bitprim_headers
# include_bitcoin_HEADERS =
bitcoin/blockchain.hpp
# include_bitcoin_blockchain_HEADERS =
bitcoin/blockchain/define.hpp
bitcoin/blockchain/settings.hpp
bitcoin/blockchain/version.hpp
# include_bitcoin_blockchain_interface_HEADERS =
bitcoin/blockchain/interface/block_chain.hpp
#bitcoin/blockchain/interface/block_fetcher.hpp
bitcoin/blockchain/interface/fast_chain.hpp
bitcoin/blockchain/interface/safe_chain.hpp
# include_bitcoin_blockchain_pools_HEADERS =
bitcoin/blockchain/pools/block_entry.hpp
bitcoin/blockchain/pools/block_organizer.hpp
bitcoin/blockchain/pools/block_pool.hpp
bitcoin/blockchain/pools/branch.hpp
bitcoin/blockchain/pools/transaction_entry.hpp
bitcoin/blockchain/pools/transaction_organizer.hpp
bitcoin/blockchain/pools/transaction_pool.hpp
#Rama
bitcoin/blockchain/pools/mempool_transaction_summary.hpp
# include_bitcoin_blockchain_populate_HEADERS =
bitcoin/blockchain/populate/populate_base.hpp
bitcoin/blockchain/populate/populate_block.hpp
bitcoin/blockchain/populate/populate_chain_state.hpp
bitcoin/blockchain/populate/populate_transaction.hpp
# include_bitcoin_blockchain_validation_HEADERS =
bitcoin/blockchain/validate/validate_block.hpp
bitcoin/blockchain/validate/validate_input.hpp
bitcoin/blockchain/validate/validate_transaction.hpp
)
foreach (_header ${_bitprim_headers})
get_filename_component(_directory "${_header}" DIRECTORY)
install(FILES "include/${_header}" DESTINATION "include/${_directory}")
endforeach()
# Export
#==============================================================================
include(CMakePackageConfigHelpers)
export(EXPORT bitprim-blockchain
FILE "${CMAKE_CURRENT_BINARY_DIR}/bitprim-blockchainTargets.cmake")
export(PACKAGE bitprim-blockchain)
if (UNIX)
set(_config_package_location "lib/cmake")
elseif (WIN32)
set(_config_package_location "cmake")
endif()
install(EXPORT bitprim-blockchain
FILE bitprim-blockchainTargets.cmake
DESTINATION ${_config_package_location})
configure_file(bitprim-blockchainConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/bitprim-blockchainConfig.cmake"
@ONLY)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/bitprim-blockchainConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/bitprim-blockchainConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/bitprim-blockchainConfigVersion.cmake"
DESTINATION ${_config_package_location})