|
| 1 | +# Copyright (c) 2024-present The Bitcoin Core developers |
| 2 | +# Distributed under the MIT software license, see the accompanying |
| 3 | +# file COPYING or https://opensource.org/license/mit/. |
| 4 | + |
| 5 | +#[=======================================================================[ |
| 6 | +FindUSDT |
| 7 | +-------- |
| 8 | +
|
| 9 | +Finds the Userspace, Statically Defined Tracing header(s). |
| 10 | +
|
| 11 | +Imported Targets |
| 12 | +^^^^^^^^^^^^^^^^ |
| 13 | +
|
| 14 | +This module provides imported target ``USDT::headers``, if |
| 15 | +USDT has been found. |
| 16 | +
|
| 17 | +Result Variables |
| 18 | +^^^^^^^^^^^^^^^^ |
| 19 | +
|
| 20 | +This module defines the following variables: |
| 21 | +
|
| 22 | +``USDT_FOUND`` |
| 23 | + "True" if USDT found. |
| 24 | +
|
| 25 | +#]=======================================================================] |
| 26 | + |
| 27 | +find_path(USDT_INCLUDE_DIR |
| 28 | + NAMES sys/sdt.h |
| 29 | +) |
| 30 | +mark_as_advanced(USDT_INCLUDE_DIR) |
| 31 | + |
| 32 | +if(USDT_INCLUDE_DIR) |
| 33 | + include(CMakePushCheckState) |
| 34 | + cmake_push_check_state(RESET) |
| 35 | + |
| 36 | + include(CheckCXXSourceCompiles) |
| 37 | + set(CMAKE_REQUIRED_INCLUDES ${USDT_INCLUDE_DIR}) |
| 38 | + check_cxx_source_compiles(" |
| 39 | + #include <sys/sdt.h> |
| 40 | +
|
| 41 | + int main() |
| 42 | + { |
| 43 | + DTRACE_PROBE(context, event); |
| 44 | + int a, b, c, d, e, f, g; |
| 45 | + DTRACE_PROBE7(context, event, a, b, c, d, e, f, g); |
| 46 | + } |
| 47 | + " HAVE_USDT_H |
| 48 | + ) |
| 49 | + |
| 50 | + cmake_pop_check_state() |
| 51 | +endif() |
| 52 | + |
| 53 | +include(FindPackageHandleStandardArgs) |
| 54 | +find_package_handle_standard_args(USDT |
| 55 | + REQUIRED_VARS USDT_INCLUDE_DIR HAVE_USDT_H |
| 56 | +) |
| 57 | + |
| 58 | +if(USDT_FOUND AND NOT TARGET USDT::headers) |
| 59 | + add_library(USDT::headers INTERFACE IMPORTED) |
| 60 | + set_target_properties(USDT::headers PROPERTIES |
| 61 | + INTERFACE_INCLUDE_DIRECTORIES "${USDT_INCLUDE_DIR}" |
| 62 | + INTERFACE_COMPILE_DEFINITIONS ENABLE_TRACING |
| 63 | + ) |
| 64 | +endif() |
0 commit comments