FindPipeWire.cmake 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # cmake-format: off
  2. # .rst: FindPipeWire
  3. # -------
  4. #
  5. # Try to find PipeWire on a Unix system.
  6. #
  7. # This will define the following variables:
  8. #
  9. # ``PIPEWIRE_FOUND`` True if (the requested version of) PipeWire is available
  10. # ``PIPEWIRE_VERSION`` The version of PipeWire ``PIPEWIRE_LIBRARIES`` This can
  11. # be passed to target_link_libraries() instead of the ``PipeWire::PipeWire``
  12. # target ``PIPEWIRE_INCLUDE_DIRS`` This should be passed to
  13. # target_include_directories() if the target is not used for linking
  14. # ``PIPEWIRE_COMPILE_FLAGS`` This should be passed to target_compile_options()
  15. # if the target is not used for linking
  16. #
  17. # If ``PIPEWIRE_FOUND`` is TRUE, it will also define the following imported
  18. # target:
  19. #
  20. # ``PipeWire::PipeWire`` The PipeWire library
  21. #
  22. # In general we recommend using the imported target, as it is easier to use.
  23. # Bear in mind, however, that if the target is in the link interface of an
  24. # exported library, it must be made available by the package config file.
  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. # cmake-format: on
  52. # Use pkg-config to get the directories and then use these values in the FIND_PATH() and FIND_LIBRARY() calls
  53. find_package(PkgConfig QUIET)
  54. pkg_search_module(PKG_PIPEWIRE QUIET libpipewire-0.3)
  55. pkg_search_module(PKG_SPA QUIET libspa-0.2)
  56. set(PIPEWIRE_COMPILE_FLAGS "${PKG_PIPEWIRE_CFLAGS}" "${PKG_SPA_CFLAGS}")
  57. set(PIPEWIRE_VERSION "${PKG_PIPEWIRE_VERSION}")
  58. find_path(
  59. PIPEWIRE_INCLUDE_DIRS
  60. NAMES pipewire/pipewire.h
  61. HINTS ${PKG_PIPEWIRE_INCLUDE_DIRS} ${PKG_PIPEWIRE_INCLUDE_DIRS}/pipewire-0.3)
  62. find_path(
  63. SPA_INCLUDE_DIRS
  64. NAMES spa/param/props.h
  65. HINTS ${PKG_SPA_INCLUDE_DIRS} ${PKG_SPA_INCLUDE_DIRS}/spa-0.2)
  66. find_library(
  67. PIPEWIRE_LIBRARIES
  68. NAMES pipewire-0.3
  69. HINTS ${PKG_PIPEWIRE_LIBRARY_DIRS})
  70. include(FindPackageHandleStandardArgs)
  71. find_package_handle_standard_args(
  72. PipeWire
  73. FOUND_VAR PIPEWIRE_FOUND
  74. REQUIRED_VARS PIPEWIRE_LIBRARIES PIPEWIRE_INCLUDE_DIRS SPA_INCLUDE_DIRS
  75. VERSION_VAR PIPEWIRE_VERSION)
  76. if(PIPEWIRE_FOUND AND NOT TARGET PipeWire::PipeWire)
  77. add_library(PipeWire::PipeWire UNKNOWN IMPORTED)
  78. set_target_properties(
  79. PipeWire::PipeWire
  80. PROPERTIES IMPORTED_LOCATION "${PIPEWIRE_LIBRARIES}"
  81. INTERFACE_COMPILE_OPTIONS "${PIPEWIRE_COMPILE_FLAGS}"
  82. INTERFACE_INCLUDE_DIRECTORIES "${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")