File: FindTraceEvent.cmake

package info (click to toggle)
kernelshark 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,744 kB
  • sloc: cpp: 12,517; ansic: 11,546; makefile: 89; sh: 89
file content (76 lines) | stat: -rw-r--r-- 2,351 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# SPDX-License-Identifier: LGPL-2.1

#[=======================================================================[.rst:
FindTraceevent
-------

Finds the traceevent library.

Imported Targets
^^^^^^^^^^^^^^^^

This module defines the :prop_tgt:`IMPORTED` targets:

``trace::event``
 Defined if the system has libtraceevent.

Result Variables
^^^^^^^^^^^^^^^^

``TraceEvent_FOUND``
  True if the system has the libtraceevent library.
``TraceEvent_VERSION``
  The version of the libtraceevent library which was found.
``TraceEvent_INCLUDE_DIRS``
  Include directories needed to use libtraceevent.
``TraceEvent_LIBRARIES``
  Libraries needed to link to libtraceevent.

Cache Variables
^^^^^^^^^^^^^^^

``TraceEvent_INCLUDE_DIR``
  The directory containing ``event-parse.h``.
``TraceEvent_LIBRARY``
  The path to the traceevent library.

#]=======================================================================]

find_package(PkgConfig QUIET)
pkg_check_modules(PC_TraceEvent QUIET libtraceevent)

set(TraceEvent_VERSION     ${PC_TraceEvent_VERSION})
set(TraceEvent_DEFINITIONS ${PC_TraceEvent_CFLAGS_OTHER})

find_path(TraceEvent_INCLUDE_DIR  NAMES event-parse.h
                                  HINTS ${PC_TraceEvent_INCLUDE_DIRS}
                                        ${PC_TraceEvent_INCLUDEDIR})

find_library(TraceEvent_LIBRARY   NAMES traceevent libtraceevent
                                  HINTS ${PC_TraceEvent_LIBDIR}
                                        ${PC_TraceEventLIBRARY_DIRS})

mark_as_advanced(TraceEvent_INCLUDE_DIR TraceEvent_LIBRARY)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(TraceEvent DEFAULT_MSG
                                  TraceEvent_LIBRARY TraceEvent_INCLUDE_DIR)

if(TraceEvent_FOUND)

  set(TraceEvent_LIBRARIES    ${TraceEvent_LIBRARY})
  set(TraceEvent_INCLUDE_DIRS ${TraceEvent_INCLUDE_DIR})

  if(NOT TARGET trace::event)
    add_library(trace::event UNKNOWN IMPORTED)

    set_target_properties(trace::event
                          PROPERTIES
                            INTERFACE_INCLUDE_DIRECTORIES "${TraceEvent_INCLUDE_DIRS}"
                            INTERFACE_COMPILE_DEFINITIONS "${TraceEvent_DEFINITIONS}"
                            IMPORTED_LINK_INTERFACE_LANGUAGES "C"
                            IMPORTED_LOCATION "${TraceEvent_LIBRARIES}")
  endif()

endif()