Skip to content

Commit

Permalink
cmake: Add systemtap-sdt optional package support
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Apr 21, 2023
1 parent e352ac6 commit d439a1b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ tristate_option(CCACHE "Use ccache for compiling." "if ccache is found." AUTO)
tristate_option(WITH_NATPMP "Enable NAT-PMP." "if libnatpmp is found." AUTO)
tristate_option(WITH_MINIUPNPC "Enable UPnP." "if libminiupnpc is found." AUTO)
tristate_option(WITH_ZMQ "Enable ZMQ notifications." "if libzmq is found." AUTO)
tristate_option(WITH_USDT
"Enable tracepoints for Userspace, Statically Defined Tracing."
"if sys/sdt.h is found."
AUTO
)

if(CXX20)
set(CMAKE_CXX_STANDARD 20)
Expand Down Expand Up @@ -147,6 +152,7 @@ message("Optional packages:")
message(" NAT-PMP ............................. ${WITH_NATPMP}")
message(" UPnP ................................ ${WITH_MINIUPNPC}")
message(" ZeroMQ .............................. ${WITH_ZMQ}")
message(" USDT tracing ........................ ${WITH_USDT}")
message("")
if(CMAKE_CROSSCOMPILING)
set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}")
Expand Down
4 changes: 4 additions & 0 deletions cmake/bitcoin-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
/* Copyright year */
#define COPYRIGHT_YEAR @COPYRIGHT_YEAR@

/* Define to 1 to enable tracepoints for Userspace, Statically Defined Tracing
*/
#cmakedefine ENABLE_TRACING 1

/* Define this symbol if you have __builtin_clzl */
#cmakedefine HAVE_BUILTIN_CLZL 1

Expand Down
21 changes: 21 additions & 0 deletions cmake/optional.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,24 @@ if(WITH_ZMQ)
message(FATAL_ERROR "libzmq requested, but not found.")
endif()
endif()

include(CheckCXXSourceCompiles)
if(WITH_USDT)
check_cxx_source_compiles("
#include <sys/sdt.h>
int main()
{
DTRACE_PROBE(\"context\", \"event\");
}
" HAVE_USDT_H
)
if(HAVE_USDT_H)
set(ENABLE_TRACING TRUE)
set(WITH_USDT ON)
elseif(WITH_USDT STREQUAL "AUTO")
set(WITH_USDT OFF)
else()
message(FATAL_ERROR "sys/sdt.h requested, but not found.")
endif()
endif()

0 comments on commit d439a1b

Please sign in to comment.