Debian Codegraph @

cmake/FindPipeWire.cmake

raw
1 # .rst: FindPipeWire
2 # -------
3 #
4 # Try to find PipeWire on a Unix system.
5 #
6 # This will define the following variables:
7 #
8 # ``PIPEWIRE_FOUND`` True if (the requested version of) PipeWire is available
9 # ``PIPEWIRE_VERSION`` The version of PipeWire ``PIPEWIRE_LIBRARIES`` This can
10 # be passed to target_link_libraries() instead of the ``PipeWire::PipeWire``
11 # target ``PIPEWIRE_INCLUDE_DIRS`` This should be passed to
12 # target_include_directories() if the target is not used for linking
13 # ``PIPEWIRE_COMPILE_FLAGS`` This should be passed to target_compile_options()
14 # if the target is not used for linking
15 #
16 # If ``PIPEWIRE_FOUND`` is TRUE, it will also define the following imported
17 # target:
18 #
19 # ``PipeWire::PipeWire`` The PipeWire library
20 #
21 # In general we recommend using the imported target, as it is easier to use.
22 # Bear in mind, however, that if the target is in the link interface of an
23 # exported library, it must be made available by the package config file.
24
25 # =============================================================================
26 # Copyright 2014 Alex Merry <[email protected]> Copyright 2014 Martin Gräßlin
27 # <[email protected]> Copyright 2018-2020 Jan Grulich <[email protected]>
28 #
29 # Redistribution and use in source and binary forms, with or without
30 # modification, are permitted provided that the following conditions are met:
31 #
32 # 1. Redistributions of source code must retain the copyright notice, this list
33 # of conditions and the following disclaimer.
34 # 2. Redistributions in binary form must reproduce the copyright notice, this
35 # list of conditions and the following disclaimer in the documentation and/or
36 # other materials provided with the distribution.
37 # 3. The name of the author may not be used to endorse or promote products
38 # derived from this software without specific prior written permission.
39 #
40 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
41 # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
42 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
43 # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
45 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
46 # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
47 # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 # POSSIBILITY OF SUCH DAMAGE.
50 # =============================================================================
51
52 # Use pkg-config to get the directories and then use these values in the
53 # FIND_PATH() and FIND_LIBRARY() calls
54 find_package(PkgConfig QUIET)
55
56 pkg_search_module(PKG_PIPEWIRE QUIET libpipewire-0.3)
57 pkg_search_module(PKG_SPA QUIET libspa-0.2)
58
59 set(PIPEWIRE_COMPILE_FLAGS "${PKG_PIPEWIRE_CFLAGS}" "${PKG_SPA_CFLAGS}")
60 set(PIPEWIRE_VERSION "${PKG_PIPEWIRE_VERSION}")
61
62 find_path(
63 PIPEWIRE_INCLUDE_DIRS
64 NAMES pipewire/pipewire.h
65 HINTS ${PKG_PIPEWIRE_INCLUDE_DIRS} ${PKG_PIPEWIRE_INCLUDE_DIRS}/pipewire-0.3)
66
67 find_path(
68 SPA_INCLUDE_DIRS
69 NAMES spa/param/props.h
70 HINTS ${PKG_SPA_INCLUDE_DIRS} ${PKG_SPA_INCLUDE_DIRS}/spa-0.2)
71
72 find_library(
73 PIPEWIRE_LIBRARIES
74 NAMES pipewire-0.3
75 HINTS ${PKG_PIPEWIRE_LIBRARY_DIRS})
76
77 include(FindPackageHandleStandardArgs)
78 find_package_handle_standard_args(
79 PipeWire
80 FOUND_VAR PIPEWIRE_FOUND
81 REQUIRED_VARS PIPEWIRE_LIBRARIES PIPEWIRE_INCLUDE_DIRS SPA_INCLUDE_DIRS
82 VERSION_VAR PIPEWIRE_VERSION)
83
84 if(PIPEWIRE_FOUND AND NOT TARGET PipeWire::PipeWire)
85 add_library(PipeWire::PipeWire UNKNOWN IMPORTED)
86 set_target_properties(
87 PipeWire::PipeWire
88 PROPERTIES IMPORTED_LOCATION "${PIPEWIRE_LIBRARIES}"
89 INTERFACE_COMPILE_OPTIONS "${PIPEWIRE_COMPILE_FLAGS}"
90 INTERFACE_INCLUDE_DIRECTORIES
91 "${PIPEWIRE_INCLUDE_DIRS};${SPA_INCLUDE_DIRS}")
92 endif()
93
94 mark_as_advanced(PIPEWIRE_LIBRARIES PIPEWIRE_INCLUDE_DIRS)
95
96 include(FeatureSummary)
97 set_package_properties(
98 PipeWire PROPERTIES
99 URL "https://www.pipewire.org"
100 DESCRIPTION "PipeWire - multimedia processing")