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.
1cmake_minimum_required(VERSION 3.22)3project(bitcoin-tidy4VERSION51.0.06DESCRIPTION "clang-tidy checks for Bitcoin Core"7LANGUAGES CXX)9include(GNUInstallDirs)11set(CMAKE_CXX_STANDARD 20)12set(CMAKE_CXX_STANDARD_REQUIRED True)13set(CMAKE_CXX_EXTENSIONS False)15set(CMAKE_DISABLE_FIND_PACKAGE_CURL ON)16set(CMAKE_DISABLE_FIND_PACKAGE_FFI ON)17set(CMAKE_DISABLE_FIND_PACKAGE_LibEdit ON)18set(CMAKE_DISABLE_FIND_PACKAGE_LibXml2 ON)19set(CMAKE_DISABLE_FIND_PACKAGE_Terminfo ON)20set(CMAKE_DISABLE_FIND_PACKAGE_ZLIB ON)21set(CMAKE_DISABLE_FIND_PACKAGE_zstd ON)23find_package(LLVM REQUIRED CONFIG)24find_program(CLANG_TIDY_EXE REQUIRED NAMES "clang-tidy-${LLVM_VERSION_MAJOR}" "clang-tidy" HINTS ${LLVM_TOOLS_BINARY_DIR})25message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")26message(STATUS "Found clang-tidy: ${CLANG_TIDY_EXE}")28add_library(bitcoin-tidy MODULE bitcoin-tidy.cpp nontrivial-threadlocal.cpp)29target_include_directories(bitcoin-tidy SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS})31# Disable RTTI and exceptions as necessary32if (MSVC)33target_compile_options(bitcoin-tidy PRIVATE /GR-)34else()35target_compile_options(bitcoin-tidy PRIVATE -fno-rtti)36target_compile_options(bitcoin-tidy PRIVATE -fno-exceptions)37endif()39if(CMAKE_HOST_APPLE)40# ld64 expects no undefined symbols by default41target_link_options(bitcoin-tidy PRIVATE -Wl,-flat_namespace)42target_link_options(bitcoin-tidy PRIVATE -Wl,-undefined -Wl,suppress)43endif()45# Add warnings46if (MSVC)47target_compile_options(bitcoin-tidy PRIVATE /W4)48else()49target_compile_options(bitcoin-tidy PRIVATE -Wall)50target_compile_options(bitcoin-tidy PRIVATE -Wextra)51endif()53if(CMAKE_VERSION VERSION_LESS 3.27)54set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "--load=${CMAKE_BINARY_DIR}/${CMAKE_SHARED_MODULE_PREFIX}bitcoin-tidy${CMAKE_SHARED_MODULE_SUFFIX}" "-checks=-*,bitcoin-*")55else()56# CLANG_TIDY_COMMAND supports generator expressions as of 3.2757set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "--load=$<TARGET_FILE:bitcoin-tidy>" "-checks=-*,bitcoin-*")58endif()60# Create a dummy library that runs clang-tidy tests as a side-effect of building61add_library(bitcoin-tidy-tests OBJECT EXCLUDE_FROM_ALL example_nontrivial-threadlocal.cpp)62add_dependencies(bitcoin-tidy-tests bitcoin-tidy)64set_target_properties(bitcoin-tidy-tests PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")67install(TARGETS bitcoin-tidy LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
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.