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.
1# Copyright (c) 2023-present The Bitcoin Core developers2# Distributed under the MIT software license, see the accompanying3# file COPYING or https://opensource.org/license/mit/.5macro(set_add_custom_command_options)6set(DEPENDS_EXPLICIT_OPT "")7if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.27)8set(DEPENDS_EXPLICIT_OPT DEPENDS_EXPLICIT_ONLY)9endif()10set(CODEGEN_OPT "")11if(POLICY CMP0171)12cmake_policy(GET CMP0171 _cmp0171_status)13if(_cmp0171_status STREQUAL "NEW")14set(CODEGEN_OPT CODEGEN)15endif()16unset(_cmp0171_status)17endif()18endmacro()20# Specifies JSON data files to be processed into corresponding21# header files for inclusion when building a target.22function(target_json_data_sources target)23set_add_custom_command_options()24foreach(json_file IN LISTS ARGN)25set(header ${CMAKE_CURRENT_BINARY_DIR}/${json_file}.h)26add_custom_command(27OUTPUT ${header}28COMMAND ${CMAKE_COMMAND} -DJSON_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${json_file} -DHEADER_PATH=${header} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromJson.cmake29DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${json_file} ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromJson.cmake30VERBATIM31${CODEGEN_OPT}32${DEPENDS_EXPLICIT_OPT}33)34target_sources(${target} PRIVATE ${header})35endforeach()36endfunction()38# Specifies raw binary data files to be processed into corresponding39# header files for inclusion when building a target.40function(target_raw_data_sources target)41cmake_parse_arguments(PARSE_ARGV 1 _ "" "NAMESPACE" "")42set_add_custom_command_options()43set(headers)44foreach(raw_file IN LISTS __UNPARSED_ARGUMENTS)45set(header ${CMAKE_CURRENT_BINARY_DIR}/${raw_file}.h)46add_custom_command(47OUTPUT ${header}48COMMAND ${CMAKE_COMMAND} -DRAW_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${raw_file} -DHEADER_PATH=${header} -DRAW_NAMESPACE=${__NAMESPACE} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromRaw.cmake49DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${raw_file} ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromRaw.cmake50VERBATIM51${CODEGEN_OPT}52${DEPENDS_EXPLICIT_OPT}53)54list(APPEND headers ${header})55target_sources(${target} PRIVATE ${header})56endforeach()57if(TARGET ${target}_raw_data_headers)58target_sources(${target}_raw_data_headers PRIVATE ${headers})59else()60add_custom_target(${target}_raw_data_headers DEPENDS ${headers})61endif()62endfunction()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.