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/.5enable_language(C)7function(add_secp256k1 subdir)8message("")9message("Configuring secp256k1 subtree...")10set(BUILD_SHARED_LIBS OFF)11set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)13# Unconditionally prevent secp's symbols from being exported by our libs14set(CMAKE_C_VISIBILITY_PRESET hidden)15set(SECP256K1_ENABLE_API_VISIBILITY_ATTRIBUTES OFF CACHE BOOL "" FORCE)17set(SECP256K1_ENABLE_MODULE_ECDH OFF CACHE BOOL "" FORCE)18set(SECP256K1_ENABLE_MODULE_RECOVERY ON CACHE BOOL "" FORCE)19set(SECP256K1_ENABLE_MODULE_MUSIG ON CACHE BOOL "" FORCE)20set(SECP256K1_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE)21set(SECP256K1_BUILD_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE)22set(SECP256K1_BUILD_EXHAUSTIVE_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE)23if(NOT BUILD_TESTS)24# Always skip the ctime tests, if we are building no other tests.25# Otherwise, they are built if Valgrind is available. See SECP256K1_VALGRIND.26set(SECP256K1_BUILD_CTIME_TESTS ${BUILD_TESTS} CACHE BOOL "" FORCE)27endif()28set(SECP256K1_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)29include(GetTargetInterface)30# -fsanitize and related flags apply to both C++ and C,31# so we can pass them down to libsecp256k1 as CFLAGS and LDFLAGS.32get_target_interface(SECP256K1_APPEND_CFLAGS "" sanitize_interface COMPILE_OPTIONS)33string(STRIP "${SECP256K1_APPEND_CFLAGS} ${APPEND_CPPFLAGS}" SECP256K1_APPEND_CFLAGS)34string(STRIP "${SECP256K1_APPEND_CFLAGS} ${APPEND_CFLAGS}" SECP256K1_APPEND_CFLAGS)35set(SECP256K1_APPEND_CFLAGS ${SECP256K1_APPEND_CFLAGS} CACHE STRING "" FORCE)36get_target_interface(SECP256K1_APPEND_LDFLAGS "" sanitize_interface LINK_OPTIONS)37string(STRIP "${SECP256K1_APPEND_LDFLAGS} ${APPEND_LDFLAGS}" SECP256K1_APPEND_LDFLAGS)38set(SECP256K1_APPEND_LDFLAGS ${SECP256K1_APPEND_LDFLAGS} CACHE STRING "" FORCE)39# We want to build libsecp256k1 with the most tested RelWithDebInfo configuration.40foreach(config IN LISTS CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES)41if(config STREQUAL "")42continue()43endif()44string(TOUPPER "${config}" config)45set(CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_RELWITHDEBINFO}")46endforeach()47# If the CFLAGS environment variable is defined during building depends48# and configuring this build system, its content might be duplicated.49if(DEFINED ENV{CFLAGS})50deduplicate_flags(CMAKE_C_FLAGS)51endif()53add_subdirectory(${subdir})54set_target_properties(secp256k1 PROPERTIES55EXCLUDE_FROM_ALL TRUE56)57endfunction()
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.