Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
501# Some compilers (gcc) ignore unknown -Wno-* options, but warn about all502# unknown options if any other warning is produced. Test the -Wfoo case, and503# set the -Wno-foo case if it works.504try_append_cxx_flags("-Wunused-parameter" TARGET warn_interface SKIP_LINK505IF_CHECK_PASSED "-Wno-unused-parameter"506)507endif()509configure_file(cmake/script/Coverage.cmake Coverage.cmake USE_SOURCE_PERMISSIONS COPYONLY)510configure_file(cmake/script/CoverageInclude.cmake.in CoverageInclude.cmake USE_SOURCE_PERMISSIONS @ONLY)511configure_file(cmake/script/cov_tool_wrapper.sh.in cov_tool_wrapper.sh.in USE_SOURCE_PERMISSIONS COPYONLY)512configure_file(contrib/filter-lcov.py filter-lcov.py USE_SOURCE_PERMISSIONS COPYONLY)514# Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review.515try_append_cxx_flags("-fno-extended-identifiers" TARGET core_interface SKIP_LINK)517# Set `-fmacro-prefix-map`, so that source file names are expanded without the518# src prefix.519try_append_cxx_flags("-fmacro-prefix-map=A=B" TARGET core_interface SKIP_LINK520IF_CHECK_PASSED "-fmacro-prefix-map=${PROJECT_SOURCE_DIR}/src=."521)523# GCC versions 13.2 (and earlier) are subject to a class of bugs, see524# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348 and the meta bug525# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111843. To work around that, set526# -fstack-reuse=none for all gcc builds. (Only gcc understands this flag).527try_append_cxx_flags("-fstack-reuse=none" TARGET core_interface)529if(MSVC)530try_append_linker_flag("/DYNAMICBASE" TARGET core_interface)531try_append_linker_flag("/HIGHENTROPYVA" TARGET core_interface)532try_append_linker_flag("/NXCOMPAT" TARGET core_interface)533else()535# _FORTIFY_SOURCE requires that there is some level of optimization,536# otherwise it does nothing and just creates a compiler warning.537try_append_cxx_flags("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"538RESULT_VAR cxx_supports_fortify_source539SOURCE "int main() {540# if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0541#error542#endif543}"544)545if(cxx_supports_fortify_source)546target_compile_options(core_interface INTERFACE547-U_FORTIFY_SOURCE548-D_FORTIFY_SOURCE=3549)550endif()551unset(cxx_supports_fortify_source)553try_append_cxx_flags("-Wstack-protector" TARGET core_interface SKIP_LINK)554try_append_cxx_flags("-fstack-protector-all" TARGET core_interface)555try_append_cxx_flags("-fcf-protection=full" TARGET core_interface)557if(MINGW)558# stack-clash-protection is a no-op for Windows.559# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 for more details.560else()561try_append_cxx_flags("-fstack-clash-protection" TARGET core_interface)562endif()564if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")565if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")566try_append_cxx_flags("-mbranch-protection=bti" TARGET core_interface SKIP_LINK)567else()568try_append_cxx_flags("-mbranch-protection=standard" TARGET core_interface SKIP_LINK)569endif()570endif()572try_append_linker_flag("-Wl,--enable-reloc-section" TARGET core_interface)573try_append_linker_flag("-Wl,--dynamicbase" TARGET core_interface)574try_append_linker_flag("-Wl,--nxcompat" TARGET core_interface)575try_append_linker_flag("-Wl,--high-entropy-va" TARGET core_interface)576try_append_linker_flag("-Wl,-z,relro" TARGET core_interface)577try_append_linker_flag("-Wl,-z,now" TARGET core_interface)578# TODO: This can be dropped once Bitcoin Core no longer supports579# NetBSD 10.0 or if upstream fix is backported.580# NetBSD's dynamic linker ld.elf_so < 11.0 supports exactly 2581# `PT_LOAD` segments and binaries linked with `-z separate-code`582# have 4 `PT_LOAD` segments.583# Relevant discussions:584# - https://github.com/bitcoin/bitcoin/pull/28724#issuecomment-2589347934585# - https://mail-index.netbsd.org/tech-userlevel/2023/01/05/msg013666.html586if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD" AND CMAKE_SYSTEM_VERSION VERSION_LESS 11.0)587try_append_linker_flag("-Wl,-z,noseparate-code" TARGET core_interface)588else()589try_append_linker_flag("-Wl,-z,separate-code" TARGET core_interface)590endif()591if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")592try_append_linker_flag("-Wl,-fixup_chains" TARGET core_interface)593endif()594endif()596if(REDUCE_EXPORTS)597set(CMAKE_CXX_VISIBILITY_PRESET hidden)598set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)599try_append_linker_flag("-Wl,--exclude-libs,ALL" TARGET core_interface)600try_append_linker_flag("-Wl,-no_exported_symbols" VAR CMAKE_EXE_LINKER_FLAGS)601endif()603# Prefer Unix-style package components over frameworks on macOS.604# This improves compatibility with Python version managers.605set(Python3_FIND_FRAMEWORK LAST CACHE STRING "")606# Search for generic names before more specialized ones. This607# improves compatibility with Python version managers that use shims.608set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "")609mark_as_advanced(Python3_FIND_FRAMEWORK Python3_FIND_UNVERSIONED_NAMES)610find_package(Python3 3.10 COMPONENTS Interpreter)611if(NOT TARGET Python3::Interpreter)612list(APPEND configure_warnings613"Minimum required Python not found."614)615endif()617target_compile_definitions(core_interface INTERFACE ${DEPENDS_COMPILE_DEFINITIONS})618target_compile_definitions(core_interface_relwithdebinfo INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_RELWITHDEBINFO})619target_compile_definitions(core_interface_debug INTERFACE ${DEPENDS_COMPILE_DEFINITIONS_DEBUG})621# If the {CXX,LD}FLAGS environment variables are defined during building depends622# and configuring this build system, their content might be duplicated.623if(DEFINED ENV{CXXFLAGS})624deduplicate_flags(CMAKE_CXX_FLAGS)625endif()626if(DEFINED ENV{LDFLAGS})627deduplicate_flags(CMAKE_EXE_LINKER_FLAGS)628endif()630if(BUILD_TESTS)631enable_testing()632endif()634if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.29)635# have "make test" depend on "make all"636set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE)637endif()639add_subdirectory(test)640add_subdirectory(doc)642add_subdirectory(src)644include(Maintenance)645setup_split_debug_script()646add_windows_deploy_target()647add_macos_deploy_target()649message("\n")650message("Configure summary")651message("=================")652message("Executables:")653message(" bitcoin ............................. ${BUILD_BITCOIN_BIN}")654message(" bitcoind ............................ ${BUILD_DAEMON}")655if(BUILD_DAEMON AND ENABLE_IPC)656set(bitcoin_daemon_status ON)657else()658set(bitcoin_daemon_status OFF)659endif()660message(" bitcoin-node (multiprocess) ......... ${bitcoin_daemon_status}")661message(" bitcoin-qt (GUI) .................... ${BUILD_GUI}")662if(BUILD_GUI AND ENABLE_IPC)663set(bitcoin_gui_status ON)664else()665set(bitcoin_gui_status OFF)666endif()667message(" bitcoin-gui (GUI, multiprocess) ..... ${bitcoin_gui_status}")668message(" bitcoin-cli ......................... ${BUILD_CLI}")669message(" bitcoin-tx .......................... ${BUILD_TX}")670message(" bitcoin-util ........................ ${BUILD_UTIL}")671message(" bitcoin-wallet ...................... ${BUILD_WALLET_TOOL}")672message(" bitcoin-chainstate (experimental) ... ${BUILD_UTIL_CHAINSTATE}")673message(" libbitcoinkernel (experimental) ..... ${BUILD_KERNEL_LIB}")674message(" kernel-test (experimental) .......... ${BUILD_KERNEL_TEST}")675message("Optional features:")676message(" wallet support ...................... ${ENABLE_WALLET}")677message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}")678message(" ZeroMQ .............................. ${WITH_ZMQ}")679if(ENABLE_IPC)680if (WITH_EXTERNAL_LIBMULTIPROCESS)681set(ipc_status "ON (with external libmultiprocess)")682else()683set(ipc_status ON)684endif()685else()686set(ipc_status OFF)687endif()688message(" IPC ................................. ${ipc_status}")689message(" Embedded ASMap ...................... ${WITH_EMBEDDED_ASMAP}")690message(" USDT tracing ........................ ${WITH_USDT}")691message(" QR code (GUI) ....................... ${WITH_QRENCODE}")692message(" DBus (GUI) .......................... ${WITH_DBUS}")693message("Tests:")694message(" test_bitcoin ........................ ${BUILD_TESTS}")695message(" test_bitcoin-qt ..................... ${BUILD_GUI_TESTS}")696message(" bench_bitcoin ....................... ${BUILD_BENCH}")697message(" fuzz binary ......................... ${BUILD_FUZZ_BINARY}")698message("")699if(CMAKE_CROSSCOMPILING)700set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}")701else()702set(cross_status "FALSE")703endif()704message("Cross compiling ....................... ${cross_status}")705message("C++ compiler .......................... ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, ${CMAKE_CXX_COMPILER}")706include(FlagsSummary)707flags_summary()708message("Treat compiler warnings as errors ..... ${CMAKE_COMPILE_WARNING_AS_ERROR}")709message("Use ccache for compiling .............. ${WITH_CCACHE}")710message("\n")711if(configure_warnings)712message(" ******\n")713foreach(warning IN LISTS configure_warnings)714message(WARNING "${warning}")715endforeach()716message(" ******\n")717message(AUTHOR_WARNING "Warnings have been encountered!")718endif()720# We want all build properties to be encapsulated properly.721include(WarnAboutGlobalProperties)