Skip to content

Commit

Permalink
Update CMake build system for Namecoin.
Browse files Browse the repository at this point in the history
This updates the new CMake-based build system for Namecoin:  Rebranding
the key outputs (that are installed, not renaming internal libraries
and things like that), and adding the Namecoin-specific files.
  • Loading branch information
domob1812 committed Sep 5, 2024
1 parent b35a94a commit 1805511
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 103 deletions.
60 changes: 30 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif()
#=============================
# Project / Package metadata
#=============================
set(PACKAGE_NAME "Bitcoin Core")
set(PACKAGE_NAME "Namecoin Core")
set(CLIENT_VERSION_MAJOR 28)
set(CLIENT_VERSION_MINOR 99)
set(CLIENT_VERSION_BUILD 0)
Expand All @@ -46,10 +46,10 @@ set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
CMAKE_CXX_LINK_EXECUTABLE
)

project(BitcoinCore
project(NamecoinCore
VERSION ${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_BUILD}
DESCRIPTION "Bitcoin client software"
HOMEPAGE_URL "https://bitcoincore.org/"
DESCRIPTION "Namecoin client software"
HOMEPAGE_URL "https://namecoin.org/"
LANGUAGES NONE
)

Expand All @@ -60,7 +60,7 @@ endif()

set(COPYRIGHT_HOLDERS "The %s developers")
set(COPYRIGHT_HOLDERS_FINAL "The ${PACKAGE_NAME} developers")
set(PACKAGE_BUGREPORT "https://github.com/bitcoin/bitcoin/issues")
set(PACKAGE_BUGREPORT "https://github.com/namecoin/namecoin-core/issues")

#=============================
# Language setup
Expand All @@ -82,16 +82,16 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/module)
#=============================
include(CMakeDependentOption)
# When adding a new option, end the <help_text> with a full stop for consistency.
option(BUILD_DAEMON "Build bitcoind executable." ON)
option(BUILD_GUI "Build bitcoin-qt executable." OFF)
option(BUILD_CLI "Build bitcoin-cli executable." ON)
option(BUILD_DAEMON "Build namecoind executable." ON)
option(BUILD_GUI "Build namecoin-qt executable." OFF)
option(BUILD_CLI "Build namecoin-cli executable." ON)

option(BUILD_TESTS "Build test_bitcoin executable." ON)
option(BUILD_TX "Build bitcoin-tx executable." ${BUILD_TESTS})
option(BUILD_UTIL "Build bitcoin-util executable." ${BUILD_TESTS})
option(BUILD_TESTS "Build test_namecoin executable." ON)
option(BUILD_TX "Build namecoin-tx executable." ${BUILD_TESTS})
option(BUILD_UTIL "Build namecoin-util executable." ${BUILD_TESTS})

option(BUILD_UTIL_CHAINSTATE "Build experimental bitcoin-chainstate executable." OFF)
option(BUILD_KERNEL_LIB "Build experimental bitcoinkernel library." ${BUILD_UTIL_CHAINSTATE})
option(BUILD_UTIL_CHAINSTATE "Build experimental namecoin-chainstate executable." OFF)
option(BUILD_KERNEL_LIB "Build experimental namecoinkernel library." ${BUILD_UTIL_CHAINSTATE})

option(ENABLE_WALLET "Enable wallet." ON)
option(WITH_SQLITE "Enable SQLite wallet support." ${ENABLE_WALLET})
Expand Down Expand Up @@ -122,7 +122,7 @@ if(WITH_BDB)
endif()
endif()
endif()
cmake_dependent_option(BUILD_WALLET_TOOL "Build bitcoin-wallet tool." ${BUILD_TESTS} "ENABLE_WALLET" OFF)
cmake_dependent_option(BUILD_WALLET_TOOL "Build namecoin-wallet tool." ${BUILD_TESTS} "ENABLE_WALLET" OFF)

option(ENABLE_HARDENING "Attempt to harden the resulting executables." ON)
option(REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting executables." OFF)
Expand Down Expand Up @@ -167,15 +167,15 @@ endif()

cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "CMAKE_SYSTEM_NAME STREQUAL \"Linux\" AND BUILD_GUI" OFF)

option(WITH_MULTIPROCESS "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables. Requires libmultiprocess library. Experimental." OFF)
option(WITH_MULTIPROCESS "Build multiprocess namecoin-node and namecoin-gui executables in addition to monolithic namecoind and namecoin-qt executables. Requires libmultiprocess library. Experimental." OFF)
if(WITH_MULTIPROCESS)
find_package(Libmultiprocess COMPONENTS Lib)
find_package(LibmultiprocessNative COMPONENTS Bin
NAMES Libmultiprocess
)
endif()

cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_GUI;BUILD_TESTS" OFF)
cmake_dependent_option(BUILD_GUI_TESTS "Build test_namecoin-qt executable." ON "BUILD_GUI;BUILD_TESTS" OFF)
if(BUILD_GUI)
set(qt_components Core Gui Widgets LinguistTools)
if(ENABLE_WALLET)
Expand All @@ -194,7 +194,7 @@ if(BUILD_GUI)
unset(qt_components)
endif()

option(BUILD_BENCH "Build bench_bitcoin executable." OFF)
option(BUILD_BENCH "Build bench_namecoin executable." OFF)
option(BUILD_FUZZ_BINARY "Build fuzz binary." OFF)
cmake_dependent_option(BUILD_FOR_FUZZING "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF "NOT MSVC" OFF)

Expand Down Expand Up @@ -597,21 +597,21 @@ message("\n")
message("Configure summary")
message("=================")
message("Executables:")
message(" bitcoind ............................ ${BUILD_DAEMON}")
message(" bitcoin-node (multiprocess) ......... ${WITH_MULTIPROCESS}")
message(" bitcoin-qt (GUI) .................... ${BUILD_GUI}")
message(" namecoind ............................ ${BUILD_DAEMON}")
message(" namecoin-node (multiprocess) ......... ${WITH_MULTIPROCESS}")
message(" namecoin-qt (GUI) .................... ${BUILD_GUI}")
if(BUILD_GUI AND WITH_MULTIPROCESS)
set(bitcoin_gui_status ON)
else()
set(bitcoin_gui_status OFF)
endif()
message(" bitcoin-gui (GUI, multiprocess) ..... ${bitcoin_gui_status}")
message(" bitcoin-cli ......................... ${BUILD_CLI}")
message(" bitcoin-tx .......................... ${BUILD_TX}")
message(" bitcoin-util ........................ ${BUILD_UTIL}")
message(" bitcoin-wallet ...................... ${BUILD_WALLET_TOOL}")
message(" bitcoin-chainstate (experimental) ... ${BUILD_UTIL_CHAINSTATE}")
message(" libbitcoinkernel (experimental) ..... ${BUILD_KERNEL_LIB}")
message(" namecoin-gui (GUI, multiprocess) ..... ${bitcoin_gui_status}")
message(" namecoin-cli ......................... ${BUILD_CLI}")
message(" namecoin-tx .......................... ${BUILD_TX}")
message(" namecoin-util ........................ ${BUILD_UTIL}")
message(" namecoin-wallet ...................... ${BUILD_WALLET_TOOL}")
message(" namecoin-chainstate (experimental) ... ${BUILD_UTIL_CHAINSTATE}")
message(" libnamecoinkernel (experimental) ..... ${BUILD_KERNEL_LIB}")
message("Optional features:")
message(" wallet support ...................... ${ENABLE_WALLET}")
if(ENABLE_WALLET)
Expand All @@ -627,9 +627,9 @@ message(" USDT tracing ........................ ${WITH_USDT}")
message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
message(" DBus (GUI, Linux only) .............. ${WITH_DBUS}")
message("Tests:")
message(" test_bitcoin ........................ ${BUILD_TESTS}")
message(" test_bitcoin-qt ..................... ${BUILD_GUI_TESTS}")
message(" bench_bitcoin ....................... ${BUILD_BENCH}")
message(" test_namecoin ........................ ${BUILD_TESTS}")
message(" test_namecoin-qt ..................... ${BUILD_GUI_TESTS}")
message(" bench_namecoin ....................... ${BUILD_BENCH}")
message(" fuzz binary ......................... ${BUILD_FUZZ_BINARY}")
message("")
if(CMAKE_CROSSCOMPILING)
Expand Down
62 changes: 35 additions & 27 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ add_library(bitcoin_consensus STATIC EXCLUDE_FROM_ALL
primitives/transaction.cpp
pubkey.cpp
script/interpreter.cpp
script/names.cpp
script/script.cpp
script/script_error.cpp
uint256.cpp
Expand Down Expand Up @@ -132,6 +133,9 @@ add_library(bitcoin_common STATIC EXCLUDE_FROM_ALL
key.cpp
key_io.cpp
merkleblock.cpp
names/applications.cpp
names/common.cpp
names/encoding.cpp
net_permissions.cpp
net_types.cpp
netaddress.cpp
Expand Down Expand Up @@ -171,20 +175,20 @@ if(ENABLE_WALLET)
add_subdirectory(wallet)

if(BUILD_WALLET_TOOL)
add_executable(bitcoin-wallet
add_executable(namecoin-wallet
bitcoin-wallet.cpp
init/bitcoin-wallet.cpp
wallet/wallettool.cpp
)
add_windows_resources(bitcoin-wallet bitcoin-wallet-res.rc)
target_link_libraries(bitcoin-wallet
add_windows_resources(namecoin-wallet bitcoin-wallet-res.rc)
target_link_libraries(namecoin-wallet
core_interface
bitcoin_wallet
bitcoin_common
bitcoin_util
Boost::headers
)
list(APPEND installable_targets bitcoin-wallet)
list(APPEND installable_targets namecoin-wallet)
endif()
endif()

Expand All @@ -209,6 +213,7 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
index/base.cpp
index/blockfilterindex.cpp
index/coinstatsindex.cpp
index/namehash.cpp
index/txindex.cpp
init.cpp
kernel/chain.cpp
Expand All @@ -219,6 +224,8 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
kernel/disconnected_transactions.cpp
kernel/mempool_removal_reason.cpp
mapport.cpp
names/main.cpp
names/mempool.cpp
net.cpp
net_processing.cpp
netgroup.cpp
Expand Down Expand Up @@ -264,6 +271,7 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
rpc/fees.cpp
rpc/mempool.cpp
rpc/mining.cpp
rpc/names.cpp
rpc/net.cpp
rpc/node.cpp
rpc/output_script.cpp
Expand Down Expand Up @@ -305,30 +313,30 @@ target_link_libraries(bitcoin_node

# Bitcoin Core bitcoind.
if(BUILD_DAEMON)
add_executable(bitcoind
add_executable(namecoind
bitcoind.cpp
init/bitcoind.cpp
)
add_windows_resources(bitcoind bitcoind-res.rc)
target_link_libraries(bitcoind
add_windows_resources(namecoind bitcoind-res.rc)
target_link_libraries(namecoind
core_interface
bitcoin_node
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
)
list(APPEND installable_targets bitcoind)
list(APPEND installable_targets namecoind)
endif()
if(WITH_MULTIPROCESS)
add_executable(bitcoin-node
add_executable(namecoin-node
bitcoind.cpp
init/bitcoin-node.cpp
)
target_link_libraries(bitcoin-node
target_link_libraries(namecoin-node
core_interface
bitcoin_node
bitcoin_ipc
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
)
list(APPEND installable_targets bitcoin-node)
list(APPEND installable_targets namecoin-node)
endif()


Expand All @@ -345,41 +353,41 @@ target_link_libraries(bitcoin_cli

# Bitcoin Core RPC client
if(BUILD_CLI)
add_executable(bitcoin-cli bitcoin-cli.cpp)
add_windows_resources(bitcoin-cli bitcoin-cli-res.rc)
target_link_libraries(bitcoin-cli
add_executable(namecoin-cli bitcoin-cli.cpp)
add_windows_resources(namecoin-cli bitcoin-cli-res.rc)
target_link_libraries(namecoin-cli
core_interface
bitcoin_cli
bitcoin_common
bitcoin_util
$<TARGET_NAME_IF_EXISTS:libevent::libevent>
)
list(APPEND installable_targets bitcoin-cli)
list(APPEND installable_targets namecoin-cli)
endif()


if(BUILD_TX)
add_executable(bitcoin-tx bitcoin-tx.cpp)
add_windows_resources(bitcoin-tx bitcoin-tx-res.rc)
target_link_libraries(bitcoin-tx
add_executable(namecoin-tx bitcoin-tx.cpp)
add_windows_resources(namecoin-tx bitcoin-tx-res.rc)
target_link_libraries(namecoin-tx
core_interface
bitcoin_common
bitcoin_util
univalue
)
list(APPEND installable_targets bitcoin-tx)
list(APPEND installable_targets namecoin-tx)
endif()


if(BUILD_UTIL)
add_executable(bitcoin-util bitcoin-util.cpp)
add_windows_resources(bitcoin-util bitcoin-util-res.rc)
target_link_libraries(bitcoin-util
add_executable(namecoin-util bitcoin-util.cpp)
add_windows_resources(namecoin-util bitcoin-util-res.rc)
target_link_libraries(namecoin-util
core_interface
bitcoin_common
bitcoin_util
)
list(APPEND installable_targets bitcoin-util)
list(APPEND installable_targets namecoin-util)
endif()


Expand All @@ -393,7 +401,7 @@ if(BUILD_KERNEL_LIB)
endif()

if(BUILD_UTIL_CHAINSTATE)
add_executable(bitcoin-chainstate
add_executable(namecoin-chainstate
bitcoin-chainstate.cpp
)
# TODO: The `SKIP_BUILD_RPATH` property setting can be deleted
Expand All @@ -402,13 +410,13 @@ if(BUILD_UTIL_CHAINSTATE)
# 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
set_target_properties(namecoin-chainstate PROPERTIES
SKIP_BUILD_RPATH OFF
)
target_link_libraries(bitcoin-chainstate
target_link_libraries(namecoin-chainstate
PRIVATE
core_interface
bitcoinkernel
namecoinkernel
)
endif()

Expand Down
12 changes: 6 additions & 6 deletions src/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
include(GenerateHeaders)
generate_header_from_raw(data/block413567.raw)

add_executable(bench_bitcoin
add_executable(bench_namecoin
bench_bitcoin.cpp
bench.cpp
data.cpp
Expand Down Expand Up @@ -56,15 +56,15 @@ add_executable(bench_bitcoin
xor.cpp
)

target_link_libraries(bench_bitcoin
target_link_libraries(bench_namecoin
core_interface
test_util
bitcoin_node
Boost::headers
)

if(ENABLE_WALLET)
target_sources(bench_bitcoin
target_sources(bench_namecoin
PRIVATE
coin_selection.cpp
wallet_balance.cpp
Expand All @@ -73,13 +73,13 @@ if(ENABLE_WALLET)
wallet_loading.cpp
wallet_ismine.cpp
)
target_link_libraries(bench_bitcoin bitcoin_wallet)
target_link_libraries(bench_namecoin bitcoin_wallet)
endif()

add_test(NAME bench_sanity_check_high_priority
COMMAND bench_bitcoin -sanity-check -priority-level=high
COMMAND bench_namecoin -sanity-check -priority-level=high
)

install(TARGETS bench_bitcoin
install(TARGETS bench_namecoin
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
Loading

0 comments on commit 1805511

Please sign in to comment.