File: FindPipeWire.cmake

package info (click to toggle)
fluidsynth 2.4.4%2Bdfsg-1%2Bdeb13u1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,328 kB
  • sloc: ansic: 43,529; cpp: 1,434; xml: 1,020; makefile: 71; sh: 46
file content (97 lines) | stat: -rw-r--r-- 3,013 bytes parent folder | download | duplicates (2)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#[=======================================================================[.rst:
FindPipeWire
-------

Finds the PipeWire library.

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

This module provides the following imported targets, if found:

``PipeWire::PipeWire``
  The PipeWire library

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

This will define the following variables:

``PipeWire_FOUND``
  True if the system has the PipeWire library.
``PipeWire_VERSION``
  The version of the PipeWire library which was found.

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

# Use pkg-config if available
find_package(PkgConfig QUIET)
pkg_check_modules(PC_PIPEWIRE QUIET libpipewire-0.3)

# Find the headers and library
find_path(
  PipeWire_INCLUDE_DIR
  NAMES "pipewire/pipewire.h"
  HINTS "${PC_PIPEWIRE_INCLUDEDIR}"
  PATH_SUFFIXES "pipewire-0.3")

find_path(
  Spa_INCLUDE_DIR
  NAMES "spa/support/plugin.h"
  HINTS "${PC_PIPEWIRE_INCLUDEDIR}"
  PATH_SUFFIXES "spa-0.2")

find_library(
  PipeWire_LIBRARY
  NAMES "pipewire-0.3"
  HINTS "${PC_PIPEWIRE_LIBDIR}")

# Get version from pkg-config or read the version header
if(PC_PIPEWIRE_VERSION)
  set(PipeWire_VERSION "${PC_PIPEWIRE_VERSION}")
elseif(PipeWire_INCLUDE_DIR)
  file(READ "${PipeWire_INCLUDE_DIR}/pipewire/version.h" _version_h)
  string(REGEX MATCH "#define[ \t]+PW_MAJOR[ \t]+([0-9]+)" _pipewire_major_re
               "${_version_h}")
  set(_pipewire_major "${CMAKE_MATCH_1}")
  string(REGEX MATCH "#define[ \t]+PW_MINOR[ \t]+([0-9]+)" _pipewire_minor_re
               "${_version_h}")
  set(_pipewire_minor "${CMAKE_MATCH_1}")
  string(REGEX MATCH "#define[ \t]+PW_MICRO[ \t]+([0-9]+)" _pipewire_patch_re
               "${_version_h}")
  set(_pipewire_patch "${CMAKE_MATCH_1}")
  if(_pipewire_major_re
     AND _pipewire_minor_re
     AND _pipewire_patch_re)
    set(pipewire_VERSION
        "${_pipewire_major}.${_pipewire_minor}.${_pipewire_patch}")
  endif()
endif()

# Extract additional flags if pkg-config is available
if(PC_PIPEWIRE_FOUND)
  get_target_properties_from_pkg_config("${PipeWire_LIBRARY}" "PC_PIPEWIRE"
                                        "_pipewire")
endif()

# Forward the result to CMake
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
  PipeWire
  REQUIRED_VARS "PipeWire_LIBRARY" "PipeWire_INCLUDE_DIR" "Spa_INCLUDE_DIR"
  VERSION_VAR "PipeWire_VERSION")

# Create the target
if(PipeWire_FOUND AND NOT TARGET PipeWire::PipeWire)
  add_library(PipeWire::PipeWire UNKNOWN IMPORTED)
  set_target_properties(
    PipeWire::PipeWire
    PROPERTIES IMPORTED_LOCATION "${PipeWire_LIBRARY}"
               INTERFACE_COMPILE_OPTIONS "${_pipewire_compile_options}"
               INTERFACE_INCLUDE_DIRECTORIES
               "${PipeWire_INCLUDE_DIR};${Spa_INCLUDE_DIR}"
               INTERFACE_LINK_LIBRARIES "${_pipewire_link_libraries}"
               INTERFACE_LINK_DIRECTORIES "${_pipewire_link_directories}")
endif()

mark_as_advanced(PipeWire_INCLUDE_DIR Spa_INCLUDE_DIR PipeWire_LIBRARY)