-
Notifications
You must be signed in to change notification settings - Fork 406
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
547 lines (512 loc) · 14.4 KB
/
Copy pathCMakeLists.txt
File metadata and controls
547 lines (512 loc) · 14.4 KB
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
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
include(AddWindowsResources)
configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-build-config.h.in bitcoin-build-config.h USE_SOURCE_PERMISSIONS @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
#=============================
# Subprojects
#=============================
# Subprojects include subdirectories that do or could have tests
# and/or benchmark binaries, such as all subtrees and univalue.
# These need to be included before CMAKE_*_OUTPUT_DIRECTORY variables
# are set, so output locations of subproject tests and libraries are
# not overridden.
include(../cmake/crc32c.cmake)
include(../cmake/leveldb.cmake)
include(../cmake/minisketch.cmake)
add_subdirectory(univalue)
#=============================
# secp256k1 subtree
#=============================
message("")
message("Configuring secp256k1 subtree...")
set(SECP256K1_ENABLE_MODULE_GENERATOR ON CACHE BOOL "" FORCE)
set(SECP256K1_ENABLE_MODULE_RANGEPROOF ON CACHE BOOL "" FORCE)
set(SECP256K1_ENABLE_MODULE_SURJECTION ON CACHE BOOL "" FORCE)
set(SECP256K1_ENABLE_MODULE_WHITELIST ON CACHE BOOL "" FORCE)
set(SECP256K1_DISABLE_SHARED ON CACHE BOOL "" FORCE)
set(SECP256K1_ENABLE_MODULE_ECDH ON CACHE BOOL "" FORCE)
set(SECP256K1_ENABLE_MODULE_RECOVERY ON CACHE BOOL "" FORCE)
set(SECP256K1_ENABLE_MODULE_MUSIG OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_EXHAUSTIVE_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE)
if(NOT BUILD_TESTS)
# Always skip the ctime tests, if we are building no other tests.
# Otherwise, they are built if Valgrind is available. See SECP256K1_VALGRIND.
set(SECP256K1_BUILD_CTIME_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE)
endif()
set(SECP256K1_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
include(GetTargetInterface)
# -fsanitize and related flags apply to both C++ and C,
# so we can pass them down to libsecp256k1 as CFLAGS and LDFLAGS.
get_target_interface(SECP256K1_APPEND_CFLAGS "" sanitize_interface COMPILE_OPTIONS)
string(STRIP "${SECP256K1_APPEND_CFLAGS} ${APPEND_CPPFLAGS}" SECP256K1_APPEND_CFLAGS)
string(STRIP "${SECP256K1_APPEND_CFLAGS} ${APPEND_CFLAGS}" SECP256K1_APPEND_CFLAGS)
set(SECP256K1_APPEND_CFLAGS ${SECP256K1_APPEND_CFLAGS} CACHE STRING "" FORCE)
get_target_interface(SECP256K1_APPEND_LDFLAGS "" sanitize_interface LINK_OPTIONS)
string(STRIP "${SECP256K1_APPEND_LDFLAGS} ${APPEND_LDFLAGS}" SECP256K1_APPEND_LDFLAGS)
set(SECP256K1_APPEND_LDFLAGS ${SECP256K1_APPEND_LDFLAGS} CACHE STRING "" FORCE)
# We want to build libsecp256k1 with the most tested RelWithDebInfo configuration.
enable_language(C)
foreach(config IN LISTS CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES)
if(config STREQUAL "")
continue()
endif()
string(TOUPPER "${config}" config)
set(CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
endforeach()
# If the CFLAGS environment variable is defined during building depends
# and configuring this build system, its content might be duplicated.
if(DEFINED ENV{CFLAGS})
deduplicate_flags(CMAKE_C_FLAGS)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)
add_subdirectory(secp256k1)
set_target_properties(secp256k1 PROPERTIES
EXCLUDE_FROM_ALL TRUE
)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#=============================
# Elements simplicity library
#=============================
enable_language(C)
add_library(elementssimplicity STATIC EXCLUDE_FROM_ALL
simplicity/bitstream.c
simplicity/dag.c
simplicity/deserialize.c
simplicity/eval.c
simplicity/frame.c
simplicity/jets-secp256k1.c
simplicity/jets.c
simplicity/rsort.c
simplicity/sha256.c
simplicity/type.c
simplicity/typeInference.c
simplicity/elements/cmr.c
simplicity/elements/env.c
simplicity/elements/exec.c
simplicity/elements/elementsJets.c
simplicity/elements/ops.c
simplicity/elements/primitive.c
simplicity/elements/txEnv.c
)
target_include_directories(elementssimplicity
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/simplicity/include
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/simplicity
)
target_compile_definitions(elementssimplicity PRIVATE PRODUCTION)
# Simplicity requires assertions; remove NDEBUG that cmake adds for optimized builds.
target_compile_options(elementssimplicity PRIVATE -UNDEBUG)
target_compile_options(elementssimplicity PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/std:c11>
)
target_link_libraries(elementssimplicity
PRIVATE
core_interface
)
# macOS Apple Clang is stricter than Linux GCC on this vendored code
if(APPLE)
target_compile_options(elementssimplicity PRIVATE
-Wno-error=conditional-uninitialized
-Wno-error=implicit-fallthrough
)
endif()
# Set top-level target output locations.
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
endif()
add_custom_target(generate_build_info
BYPRODUCTS ${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h
COMMAND ${CMAKE_COMMAND} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake
COMMENT "Generating bitcoin-build-info.h"
VERBATIM
)
add_library(bitcoin_clientversion STATIC EXCLUDE_FROM_ALL
clientversion.cpp
)
target_link_libraries(bitcoin_clientversion
PRIVATE
core_interface
)
add_dependencies(bitcoin_clientversion generate_build_info)
add_subdirectory(crypto)
add_subdirectory(util)
if(WITH_MULTIPROCESS)
add_subdirectory(ipc)
endif()
add_library(bitcoin_consensus STATIC EXCLUDE_FROM_ALL
arith_uint256.cpp
asset.cpp
consensus/merkle.cpp
consensus/tx_check.cpp
hash.cpp
primitives/block.cpp
primitives/confidential.cpp
primitives/txwitness.cpp
primitives/transaction.cpp
primitives/bitcoin/block.cpp
primitives/bitcoin/merkleblock.cpp
primitives/bitcoin/transaction.cpp
pubkey.cpp
script/interpreter.cpp
script/script.cpp
script/script_error.cpp
uint256.cpp
)
target_link_libraries(bitcoin_consensus
PUBLIC
core_interface
bitcoin_crypto
elementssimplicity
secp256k1
)
if(WITH_ZMQ)
add_subdirectory(zmq)
endif()
# Home for common functionality shared by different executables and libraries.
# Similar to `bitcoin_util` library, but higher-level.
add_library(bitcoin_common STATIC EXCLUDE_FROM_ALL
addresstype.cpp
assetsdir.cpp
base58.cpp
bech32.cpp
blech32.cpp
blind.cpp
blindpsbt.cpp
block_proof.cpp
chain.cpp
chainparams.cpp
chainparamsbase.cpp
coins.cpp
common/args.cpp
common/bloom.cpp
common/config.cpp
common/init.cpp
common/interfaces.cpp
common/messages.cpp
common/netif.cpp
common/pcp.cpp
common/run_command.cpp
common/settings.cpp
common/signmessage.cpp
common/system.cpp
common/url.cpp
compressor.cpp
core_read.cpp
core_write.cpp
deploymentinfo.cpp
external_signer.cpp
init/common.cpp
issuance.cpp
kernel/chainparams.cpp
key.cpp
key_io.cpp
merkleblock.cpp
net_permissions.cpp
net_types.cpp
netaddress.cpp
netbase.cpp
outputtype.cpp
policy/feerate.cpp
policy/policy.cpp
pow.cpp
protocol.cpp
psbt.cpp
rpc/rawtransaction_util.cpp
rpc/request.cpp
rpc/util.cpp
scheduler.cpp
script/descriptor.cpp
script/pegins.cpp
script/miniscript.cpp
script/parsing.cpp
script/sign.cpp
script/signingprovider.cpp
script/solver.cpp
)
target_link_libraries(bitcoin_common
PUBLIC
core_interface
bitcoin_consensus
bitcoin_util
univalue
secp256k1
Boost::headers
$<TARGET_NAME_IF_EXISTS:USDT::headers>
$<$<PLATFORM_ID:Windows>:ws2_32>
)
include(InstallBinaryComponent)
if(ENABLE_WALLET)
add_subdirectory(wallet)
if(BUILD_WALLET_TOOL)
add_executable(elements-wallet
bitcoin-wallet.cpp
init/bitcoin-wallet.cpp
wallet/wallettool.cpp
)
add_windows_resources(elements-wallet bitcoin-wallet-res.rc)
target_link_libraries(elements-wallet
core_interface
bitcoin_node
bitcoin_wallet
bitcoin_common
secp256k1
)
install_binary_component(elements-wallet HAS_MANPAGE)
endif()
endif()
# P2P and RPC server functionality used by `bitcoind` and `bitcoin-qt` executables.
add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
addrdb.cpp
addrman.cpp
banman.cpp
bip324.cpp
blockencodings.cpp
blockfilter.cpp
block_proof.cpp
confidential_validation.cpp
consensus/tx_verify.cpp
dynafed.cpp
dbwrapper.cpp
deploymentstatus.cpp
flatfile.cpp
headerssync.cpp
httprpc.cpp
httpserver.cpp
i2p.cpp
index/base.cpp
index/blockfilterindex.cpp
index/coinstatsindex.cpp
index/txindex.cpp
init.cpp
kernel/chain.cpp
kernel/checks.cpp
kernel/coinstats.cpp
mainchainrpc.cpp
kernel/context.cpp
kernel/cs_main.cpp
kernel/disconnected_transactions.cpp
kernel/mempool_removal_reason.cpp
mapport.cpp
net.cpp
net_processing.cpp
netgroup.cpp
node/abort.cpp
node/blockmanager_args.cpp
node/blockstorage.cpp
node/caches.cpp
node/chainstate.cpp
node/chainstatemanager_args.cpp
node/coin.cpp
node/coins_view_args.cpp
node/connection_types.cpp
node/context.cpp
node/database_args.cpp
node/eviction.cpp
node/interface_ui.cpp
node/interfaces.cpp
node/kernel_notifications.cpp
node/mempool_args.cpp
node/mempool_persist.cpp
node/mempool_persist_args.cpp
node/miner.cpp
node/mini_miner.cpp
node/minisketchwrapper.cpp
node/peerman_args.cpp
node/psbt.cpp
node/timeoffsets.cpp
node/transaction.cpp
node/txdownloadman_impl.cpp
node/txreconciliation.cpp
node/utxo_snapshot.cpp
node/warnings.cpp
noui.cpp
pegins.cpp
policy/ephemeral_policy.cpp
policy/fees.cpp
policy/fees_args.cpp
policy/packages.cpp
policy/rbf.cpp
policy/settings.cpp
policy/truc_policy.cpp
primitives/pak.cpp
rest.cpp
rpc/blockchain.cpp
rpc/external_signer.cpp
rpc/fees.cpp
rpc/mempool.cpp
rpc/mining.cpp
rpc/net.cpp
rpc/node.cpp
rpc/output_script.cpp
rpc/rawtransaction.cpp
rpc/server.cpp
rpc/server_util.cpp
rpc/signmessage.cpp
rpc/txoutproof.cpp
script/sigcache.cpp
signet.cpp
torcontrol.cpp
txdb.cpp
txmempool.cpp
txorphanage.cpp
txrequest.cpp
validation.cpp
validationinterface.cpp
versionbits.cpp
$<$<TARGET_EXISTS:bitcoin_wallet>:wallet/init.cpp>
$<$<NOT:$<TARGET_EXISTS:bitcoin_wallet>>:dummywallet.cpp>
)
target_link_libraries(bitcoin_node
PUBLIC
core_interface
bitcoin_common
bitcoin_util
$<TARGET_NAME_IF_EXISTS:bitcoin_zmq>
leveldb
minisketch
univalue
Boost::headers
elementssimplicity
$<TARGET_NAME_IF_EXISTS:libevent::libevent>
$<TARGET_NAME_IF_EXISTS:libevent::core>
$<TARGET_NAME_IF_EXISTS:libevent::extra>
$<TARGET_NAME_IF_EXISTS:libevent::pthreads>
$<TARGET_NAME_IF_EXISTS:USDT::headers>
secp256k1
)
# Elements Core elementsd.
if(BUILD_DAEMON)
add_executable(elementsd
bitcoind.cpp
init/bitcoind.cpp
)
add_windows_resources(elementsd bitcoind-res.rc)
target_link_libraries(elementsd
core_interface
bitcoin_node
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
secp256k1
)
install_binary_component(elementsd HAS_MANPAGE)
endif()
if(WITH_MULTIPROCESS AND BUILD_DAEMON)
add_executable(elements-node
bitcoind.cpp
init/bitcoin-node.cpp
)
target_link_libraries(elements-node
core_interface
bitcoin_node
bitcoin_ipc
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
secp256k1
)
install_binary_component(elements-node)
endif()
if(WITH_MULTIPROCESS AND BUILD_TESTS)
# bitcoin_ipc_test library target is defined here in src/CMakeLists.txt
# instead of src/test/CMakeLists.txt so capnp files in src/test/ are able to
# reference capnp files in src/ipc/capnp/ by relative path. The Cap'n Proto
# compiler only allows importing by relative path when the importing and
# imported files are underneath the same compilation source prefix, so the
# source prefix must be src/, not src/test/
add_library(bitcoin_ipc_test STATIC EXCLUDE_FROM_ALL
test/ipc_test.cpp
)
target_capnp_sources(bitcoin_ipc_test ${PROJECT_SOURCE_DIR}
test/ipc_test.capnp
)
add_dependencies(bitcoin_ipc_test bitcoin_ipc_headers)
endif()
add_library(bitcoin_cli STATIC EXCLUDE_FROM_ALL
compat/stdin.cpp
rpc/client.cpp
)
target_link_libraries(bitcoin_cli
PUBLIC
core_interface
univalue
)
# Elements Core RPC client
if(BUILD_CLI)
add_executable(elements-cli bitcoin-cli.cpp)
add_windows_resources(elements-cli bitcoin-cli-res.rc)
target_link_libraries(elements-cli
core_interface
bitcoin_cli
bitcoin_common
bitcoin_util
libevent::core
libevent::extra
)
install_binary_component(elements-cli HAS_MANPAGE)
endif()
if(BUILD_TX)
add_executable(elements-tx bitcoin-tx.cpp)
add_windows_resources(elements-tx bitcoin-tx-res.rc)
target_link_libraries(elements-tx
core_interface
bitcoin_common
bitcoin_util
univalue
elementssimplicity
)
install_binary_component(elements-tx HAS_MANPAGE)
endif()
if(BUILD_UTIL)
add_executable(elements-util bitcoin-util.cpp)
add_windows_resources(elements-util bitcoin-util-res.rc)
target_link_libraries(elements-util
core_interface
bitcoin_common
bitcoin_util
elementssimplicity
)
install_binary_component(elements-util HAS_MANPAGE)
endif()
if(BUILD_GUI)
add_subdirectory(qt)
endif()
if(BUILD_KERNEL_LIB)
add_subdirectory(kernel)
endif()
if(BUILD_UTIL_CHAINSTATE)
add_executable(bitcoin-chainstate
bitcoin-chainstate.cpp
)
# TODO: The `SKIP_BUILD_RPATH` property setting can be deleted
# in the future after reordering Guix script commands to
# perform binary checks after the installation step.
# Relevant discussions:
# - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953
# - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833
set_target_properties(bitcoin-chainstate PROPERTIES
SKIP_BUILD_RPATH OFF
)
target_link_libraries(bitcoin-chainstate
PRIVATE
core_interface
bitcoinkernel
)
endif()
add_subdirectory(test/util)
if(BUILD_BENCH)
add_subdirectory(bench)
endif()
if(BUILD_TESTS)
add_subdirectory(test)
endif()
if(BUILD_FUZZ_BINARY)
add_subdirectory(test/fuzz)
endif()