FindSndio.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #[=======================================================================[.rst
  2. FindSndio
  3. ---------
  4. FindModule for Sndio and associated libraries
  5. .. versionchanged:: 3.0
  6. Updated FindModule to CMake standards
  7. Imported Targets
  8. ^^^^^^^^^^^^^^^^
  9. .. versionadded:: 2.0
  10. This module defines the :prop_tgt:`IMPORTED` target ``Sndio::Sndio``.
  11. Result Variables
  12. ^^^^^^^^^^^^^^^^
  13. This module sets the following variables:
  14. ``Sndio_FOUND``
  15. True, if all required components and the core library were found.
  16. ``Sndio_VERSION``
  17. Detected version of found Sndio libraries.
  18. Cache variables
  19. ^^^^^^^^^^^^^^^
  20. The following cache variables may also be set:
  21. ``Sndio_LIBRARY``
  22. Path to the library component of Sndio.
  23. ``Sndio_INCLUDE_DIR``
  24. Directory containing ``sndio.h``.
  25. #]=======================================================================]
  26. include(FindPackageHandleStandardArgs)
  27. find_package(PkgConfig QUIET)
  28. if(PKG_CONFIG_FOUND)
  29. pkg_search_module(PC_Sndio QUIET sndio)
  30. endif()
  31. find_path(
  32. Sndio_INCLUDE_DIR
  33. NAMES sndio.h
  34. HINTS ${PC_Sndio_INCLUDE_DIRS}
  35. PATHS /usr/include /usr/local/include
  36. DOC "Sndio include directory"
  37. )
  38. find_library(
  39. Sndio_LIBRARY
  40. NAMES sndio
  41. HINTS ${PC_Sndio_LIBRARY_DIRS}
  42. PATHS /usr/lib /usr/local/lib
  43. DOC "Sndio location"
  44. )
  45. if(PC_Sndio_VERSION VERSION_GREATER 0)
  46. set(Sndio_VERSION ${PC_Sndio_VERSION})
  47. else()
  48. if(NOT Sndio_FIND_QUIETLY)
  49. message(AUTHOR_WARNING "Failed to find Sndio version.")
  50. endif()
  51. set(Sndio_VERSION 0.0.0)
  52. endif()
  53. find_package_handle_standard_args(
  54. Sndio
  55. REQUIRED_VARS Sndio_LIBRARY Sndio_INCLUDE_DIR
  56. VERSION_VAR Sndio_VERSION
  57. REASON_FAILURE_MESSAGE "Ensure that Sndio is installed on the system."
  58. )
  59. mark_as_advanced(Sndio_INCLUDE_DIR Sndio_LIBRARY)
  60. if(Sndio_FOUND)
  61. if(NOT TARGET Sndio::Sndio)
  62. if(IS_ABSOLUTE "${Sndio_LIBRARY}")
  63. add_library(Sndio::Sndio UNKNOWN IMPORTED)
  64. set_property(TARGET Sndio::Sndio PROPERTY IMPORTED_LOCATION "${Sndio_LIBRARY}")
  65. else()
  66. add_library(Sndio::Sndio INTERFACE IMPORTED)
  67. set_property(TARGET Sndio::Sndio PROPERTY IMPORTED_LIBNAME "${Sndio_LIBRARY}")
  68. endif()
  69. set_target_properties(
  70. Sndio::Sndio
  71. PROPERTIES
  72. INTERFACE_COMPILE_OPTIONS "${PC_Sndio_CFLAGS_OTHER}"
  73. INTERFACE_INCLUDE_DIRECTORIES "${Sndio_INCLUDE_DIR}"
  74. VERSION ${Sndio_VERSION}
  75. )
  76. endif()
  77. endif()
  78. include(FeatureSummary)
  79. set_package_properties(
  80. Sndio
  81. PROPERTIES
  82. URL "https://www.sndio.org"
  83. DESCRIPTION "Sndio is a small audio and MIDI framework part of the OpenBSD project and ported to FreeBSD."
  84. )