Skip to content
Bitcoin Roots

v31.1-roots.1 · Commit 1: [PATCH 01/17] build(roots): establish v31 portability foundation

cmake/module/CheckSystemSecp256k1.cmake

Before: /dev/null · After: cmake/module/CheckSystemSecp256k1.cmake

File metadata
new file mode 100644
index 0000000000000000000000000000000000000000..c38661dd515d86db5e1df2a051c5e6b83d43307e

Download original patch · Release notes

Diff rows 1–47 of 47. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

cmake/module/CheckSystemSecp256k1.cmake ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2025-present The Bitcoin Roots developers
2
+ # Distributed under the MIT software license, see the accompanying
3
+ # file COPYING or https://opensource.org/license/mit/.
4
+
5
+ # Adapted from the Roots system-library checks for Core v31's MuSig API.
6
+ find_package(PkgConfig REQUIRED)
7
+ # Refresh this project's pkg-config prefix when an operator changes package
8
+ # search paths in an existing build. Symbol probes alone would otherwise keep
9
+ # checking the previously cached headers and library.
10
+ unset(__pkg_config_checked_libsecp256k1 CACHE)
11
+ get_cmake_property(secp_cache_variables CACHE_VARIABLES)
12
+ foreach(cache_variable IN LISTS secp_cache_variables)
13
+ if(cache_variable MATCHES "^pkgcfg_lib_libsecp256k1_")
14
+ unset(${cache_variable} CACHE)
15
+ endif()
16
+ endforeach()
17
+ unset(secp_cache_variables)
18
+ unset(cache_variable)
19
+ pkg_check_modules(libsecp256k1 REQUIRED IMPORTED_TARGET libsecp256k1)
20
+
21
+ include(CheckCXXSymbolExists)
22
+ include(CMakePushCheckState)
23
+ cmake_push_check_state(RESET)
24
+ set(CMAKE_REQUIRED_LIBRARIES PkgConfig::libsecp256k1)
25
+ set(missing_symbols)
26
+ macro(check_secp256k1_symbol header symbol)
27
+ string(TOUPPER "${symbol}" check_name)
28
+ set(check_name "libsecp256k1_HAS_${check_name}")
29
+ # Recheck after the selected package changes in an existing build directory.
30
+ unset(${check_name} CACHE)
31
+ check_cxx_symbol_exists(${symbol} ${header} ${check_name})
32
+ if(NOT ${check_name})
33
+ list(APPEND missing_symbols ${symbol})
34
+ endif()
35
+ endmacro()
36
+ check_secp256k1_symbol(secp256k1_ellswift.h secp256k1_ellswift_create)
37
+ check_secp256k1_symbol(secp256k1_extrakeys.h secp256k1_xonly_pubkey_parse)
38
+ check_secp256k1_symbol(secp256k1_recovery.h secp256k1_ecdsa_recover)
39
+ check_secp256k1_symbol(secp256k1_schnorrsig.h secp256k1_schnorrsig_verify)
40
+ check_secp256k1_symbol(secp256k1_musig.h secp256k1_musig_pubkey_agg)
41
+ check_secp256k1_symbol(secp256k1_musig.h secp256k1_musig_pubkey_get)
42
+ cmake_pop_check_state()
43
+ if(missing_symbols)
44
+ list(JOIN missing_symbols ", " missing_symbols)
45
+ message(FATAL_ERROR "System libsecp256k1 lacks required v31 APIs: ${missing_symbols}.")
46
+ endif()
47
+ add_library(secp256k1 ALIAS PkgConfig::libsecp256k1)