FindJack.cmake 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #[=======================================================================[.rst
  2. FindJack
  3. --------
  4. FindModule for Jack 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 ``Jack::Jack``.
  11. Result Variables
  12. ^^^^^^^^^^^^^^^^
  13. This module sets the following variables:
  14. ``Jack_FOUND``
  15. True, if all required components and the core library were found.
  16. ``Jack_VERSION``
  17. Detected version of found Jack libraries.
  18. Cache variables
  19. ^^^^^^^^^^^^^^^
  20. The following cache variables may also be set:
  21. ``Jack_LIBRARY``
  22. Path to the library component of Jack.
  23. ``Jack_INCLUDE_DIR``
  24. Directory containing ``jack.h``.
  25. #]=======================================================================]
  26. include(FindPackageHandleStandardArgs)
  27. find_package(PkgConfig QUIET)
  28. if(PKG_CONFIG_FOUND)
  29. pkg_search_module(PC_Jack QUIET jack)
  30. endif()
  31. find_path(
  32. Jack_INCLUDE_DIR
  33. NAMES jack/jack.h
  34. HINTS ${PC_Jack_INCLUDE_DIR}
  35. PATHS /usr/include /usr/local/include
  36. DOC "Jack include directory"
  37. )
  38. find_library(Jack_LIBRARY NAMES jack HINTS ${PC_Jack_LIBRARY_DIRS} PATHS /usr/lib /usr/local/lib DOC "Jack location")
  39. if(PC_Jack_VERSION VERSION_GREATER 0)
  40. set(Jack_VERSION ${PC_Jack_VERSION})
  41. else()
  42. if(NOT Jack_FIND_QUIETLY)
  43. message(AUTHOR_WARNING "Failed to find Jack version.")
  44. endif()
  45. set(Jack_VERSION 0.0.0)
  46. endif()
  47. find_package_handle_standard_args(
  48. Jack
  49. REQUIRED_VARS Jack_LIBRARY Jack_INCLUDE_DIR
  50. VERSION_VAR Jack_VERSION
  51. REASON_FAILURE_MESSAGE "Ensure that Jack is installed on the system."
  52. )
  53. mark_as_advanced(Jack_INCLUDE_DIR Jack_LIBRARY)
  54. if(Jack_FOUND)
  55. if(NOT TARGET Jack::Jack)
  56. if(IS_ABSOLUTE "${Jack_LIBRARY}")
  57. add_library(Jack::Jack UNKNOWN IMPORTED)
  58. set_property(TARGET Jack::Jack PROPERTY IMPORTED_LOCATION "${Jack_LIBRARY}")
  59. else()
  60. add_library(Jack::Jack INTERFACE IMPORTED)
  61. set_property(TARGET Jack::Jack PROPERTY IMPORTED_LIBNAME "${Jack_LIBRARY}")
  62. endif()
  63. set_target_properties(
  64. Jack::Jack
  65. PROPERTIES
  66. INTERFACE_COMPILE_OPTIONS "${PC_Jack_CFLAGS_OTHER}"
  67. INTERFACE_INCLUDE_DIRECTORIES "${Jack_INCLUDE_DIR}"
  68. VERSION ${Jack_VERSION}
  69. )
  70. endif()
  71. endif()
  72. include(FeatureSummary)
  73. set_package_properties(
  74. Jack
  75. PROPERTIES
  76. URL "https://www.jackaudio.org"
  77. DESCRIPTION
  78. "JACK Audio Connection Kit (or JACK) is a professional sound server API and pair of daemon implementations to provide real-time, low-latency connections for both audio and MIDI data between applications."
  79. )