FindPipeWire.cmake 4.2 KB

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