Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add CMake-based build system (6 of N) #15

Merged
merged 14 commits into from
Jul 7, 2023
Merged
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ tristate_option(WITH_USDT
AUTO
)

option(BUILD_BENCH "Build bench_bitcoin executable." ON)

if(CXX20)
set(CMAKE_CXX_STANDARD 20)
else()
Expand Down Expand Up @@ -172,6 +174,8 @@ message(" NAT-PMP ............................. ${WITH_NATPMP}")
message(" UPnP ................................ ${WITH_MINIUPNPC}")
message(" ZeroMQ .............................. ${WITH_ZMQ}")
message(" USDT tracing ........................ ${WITH_USDT}")
message("Tests:")
message(" bench_bitcoin ....................... ${BUILD_BENCH}")
message("")
if(CMAKE_CROSSCOMPILING)
set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}")
Expand Down
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,9 @@ if(BUILD_UTIL)
bitcoin_util
)
endif()


add_subdirectory(test/util)
if(BUILD_BENCH)
add_subdirectory(bench)
endif()
64 changes: 64 additions & 0 deletions src/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (c) 2023 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

include(GenerateHeaders)
generate_header_from_raw(data/block413567.raw)

add_executable(bench_bitcoin
bench_bitcoin.cpp
bench.cpp
data.cpp
nanobench.cpp
${CMAKE_CURRENT_BINARY_DIR}/data/block413567.raw.h
# Benchmarks:
addrman.cpp
base58.cpp
bech32.cpp
block_assemble.cpp
ccoins_caching.cpp
chacha20.cpp
chacha_poly_aead.cpp
checkblock.cpp
checkqueue.cpp
crypto_hash.cpp
descriptors.cpp
duplicate_inputs.cpp
examples.cpp
gcs_filter.cpp
hashpadding.cpp
load_external.cpp
lockedpool.cpp
logging.cpp
mempool_eviction.cpp
mempool_stress.cpp
merkle_root.cpp
peer_eviction.cpp
poly1305.cpp
pool.cpp
prevector.cpp
rollingbloom.cpp
rpc_blockchain.cpp
rpc_mempool.cpp
strencodings.cpp
util_time.cpp
verify_script.cpp
)

target_link_libraries(bench_bitcoin
test_util
leveldb
univalue
Boost::headers
)

if(ENABLE_WALLET)
target_sources(bench_bitcoin
PRIVATE
coin_selection.cpp
wallet_balance.cpp
wallet_create_tx.cpp
wallet_loading.cpp
)
target_link_libraries(bench_bitcoin bitcoin_wallet)
endif()
33 changes: 33 additions & 0 deletions src/test/util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2023 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

add_library(test_util STATIC EXCLUDE_FROM_ALL
blockfilter.cpp
coins.cpp
json.cpp
logging.cpp
mining.cpp
net.cpp
script.cpp
setup_common.cpp
str.cpp
transaction_utils.cpp
txmempool.cpp
validation.cpp
)
target_link_libraries(test_util
PRIVATE
bitcoin_common
bitcoin_node
leveldb
univalue
Boost::headers
)

if(ENABLE_WALLET)
target_sources(test_util
PRIVATE
../../wallet/test/util.cpp

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is there a particular reason these are relative paths? Otherwise, I'd prefer an absolute path for these (also in the following commits).

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can improve it later, after dropping Autotools, by moving source files into better directories.

)
endif()