Skip to content

Commit d439a1b

Browse files
committed
cmake: Add systemtap-sdt optional package support
1 parent e352ac6 commit d439a1b

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ tristate_option(CCACHE "Use ccache for compiling." "if ccache is found." AUTO)
5050
tristate_option(WITH_NATPMP "Enable NAT-PMP." "if libnatpmp is found." AUTO)
5151
tristate_option(WITH_MINIUPNPC "Enable UPnP." "if libminiupnpc is found." AUTO)
5252
tristate_option(WITH_ZMQ "Enable ZMQ notifications." "if libzmq is found." AUTO)
53+
tristate_option(WITH_USDT
54+
"Enable tracepoints for Userspace, Statically Defined Tracing."
55+
"if sys/sdt.h is found."
56+
AUTO
57+
)
5358

5459
if(CXX20)
5560
set(CMAKE_CXX_STANDARD 20)
@@ -147,6 +152,7 @@ message("Optional packages:")
147152
message(" NAT-PMP ............................. ${WITH_NATPMP}")
148153
message(" UPnP ................................ ${WITH_MINIUPNPC}")
149154
message(" ZeroMQ .............................. ${WITH_ZMQ}")
155+
message(" USDT tracing ........................ ${WITH_USDT}")
150156
message("")
151157
if(CMAKE_CROSSCOMPILING)
152158
set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}")

cmake/bitcoin-config.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
/* Copyright year */
3434
#define COPYRIGHT_YEAR @COPYRIGHT_YEAR@
3535

36+
/* Define to 1 to enable tracepoints for Userspace, Statically Defined Tracing
37+
*/
38+
#cmakedefine ENABLE_TRACING 1
39+
3640
/* Define this symbol if you have __builtin_clzl */
3741
#cmakedefine HAVE_BUILTIN_CLZL 1
3842

cmake/optional.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,24 @@ if(WITH_ZMQ)
8585
message(FATAL_ERROR "libzmq requested, but not found.")
8686
endif()
8787
endif()
88+
89+
include(CheckCXXSourceCompiles)
90+
if(WITH_USDT)
91+
check_cxx_source_compiles("
92+
#include <sys/sdt.h>
93+
94+
int main()
95+
{
96+
DTRACE_PROBE(\"context\", \"event\");
97+
}
98+
" HAVE_USDT_H
99+
)
100+
if(HAVE_USDT_H)
101+
set(ENABLE_TRACING TRUE)
102+
set(WITH_USDT ON)
103+
elseif(WITH_USDT STREQUAL "AUTO")
104+
set(WITH_USDT OFF)
105+
else()
106+
message(FATAL_ERROR "sys/sdt.h requested, but not found.")
107+
endif()
108+
endif()

0 commit comments

Comments
 (0)