1
0

FindPipeWire.cmake 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. # Copyright 2014 Alex Merry <[email protected]> Copyright 2014 Martin Gräßlin
  26. # <[email protected]> Copyright 2018-2020 Jan Grulich <[email protected]>
  27. #
  28. # Redistribution and use in source and binary forms, with or without
  29. # modification, are permitted provided that the following conditions are met:
  30. #
  31. # 1. Redistributions of source code must retain the copyright notice, this list
  32. # of conditions and the following disclaimer.
  33. # 2. Redistributions in binary form must reproduce the copyright notice, this
  34. # list of conditions and the following disclaimer in the documentation and/or
  35. # other materials provided with the distribution.
  36. # 3. The name of the author may not be used to endorse or promote products
  37. # derived from this software without specific prior written permission.
  38. #
  39. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  40. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  41. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  42. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  43. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  44. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  45. # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  46. # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  47. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  48. # POSSIBILITY OF SUCH DAMAGE.
  49. # =============================================================================
  50. # Use pkg-config to get the directories and then use these values in the
  51. # FIND_PATH() and FIND_LIBRARY() calls
  52. find_package(PkgConfig QUIET)
  53. pkg_search_module(PKG_PIPEWIRE QUIET libpipewire-0.3)
  54. pkg_search_module(PKG_SPA QUIET libspa-0.2)
  55. set(PIPEWIRE_COMPILE_FLAGS "${PKG_PIPEWIRE_CFLAGS}" "${PKG_SPA_CFLAGS}")
  56. set(PIPEWIRE_VERSION "${PKG_PIPEWIRE_VERSION}")
  57. find_path(
  58. PIPEWIRE_INCLUDE_DIRS
  59. NAMES pipewire/pipewire.h
  60. HINTS ${PKG_PIPEWIRE_INCLUDE_DIRS} ${PKG_PIPEWIRE_INCLUDE_DIRS}/pipewire-0.3)
  61. find_path(
  62. SPA_INCLUDE_DIRS
  63. NAMES spa/param/props.h
  64. HINTS ${PKG_SPA_INCLUDE_DIRS} ${PKG_SPA_INCLUDE_DIRS}/spa-0.2)
  65. find_library(
  66. PIPEWIRE_LIBRARIES
  67. NAMES pipewire-0.3
  68. HINTS ${PKG_PIPEWIRE_LIBRARY_DIRS})
  69. include(FindPackageHandleStandardArgs)
  70. find_package_handle_standard_args(
  71. PipeWire
  72. FOUND_VAR PIPEWIRE_FOUND
  73. REQUIRED_VARS PIPEWIRE_LIBRARIES PIPEWIRE_INCLUDE_DIRS SPA_INCLUDE_DIRS
  74. VERSION_VAR PIPEWIRE_VERSION)
  75. if(PIPEWIRE_FOUND AND NOT TARGET PipeWire::PipeWire)
  76. add_library(PipeWire::PipeWire UNKNOWN IMPORTED)
  77. set_target_properties(
  78. PipeWire::PipeWire
  79. PROPERTIES IMPORTED_LOCATION "${PIPEWIRE_LIBRARIES}"
  80. INTERFACE_COMPILE_OPTIONS "${PIPEWIRE_COMPILE_FLAGS}"
  81. INTERFACE_INCLUDE_DIRECTORIES
  82. "${PIPEWIRE_INCLUDE_DIRS};${SPA_INCLUDE_DIRS}")
  83. endif()
  84. mark_as_advanced(PIPEWIRE_LIBRARIES PIPEWIRE_INCLUDE_DIRS)
  85. include(FeatureSummary)
  86. set_package_properties(
  87. PipeWire PROPERTIES
  88. URL "https://www.pipewire.org"
  89. DESCRIPTION "PipeWire - multimedia processing")