FindMPV.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ###############################################################################
  2. # CMake module to search for the mpv libraries.
  3. #
  4. # WARNING: This module is experimental work in progress.
  5. #
  6. # Based one FindVLC.cmake by:
  7. # Copyright (c) 2011 Michael Jansen <info@michael-jansen.biz>
  8. # Modified by Tobias Hieta <tobias@hieta.se>
  9. #
  10. # Redistribution and use is allowed according to the terms of the BSD license.
  11. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  12. #
  13. ###############################################################################
  14. #
  15. ### Global Configuration Section
  16. #
  17. SET(_MPV_REQUIRED_VARS MPV_INCLUDE_DIR MPV_LIBRARY)
  18. #
  19. ### MPV uses pkgconfig.
  20. #
  21. if(PKG_CONFIG_FOUND)
  22. pkg_check_modules(PC_MPV QUIET mpv)
  23. endif(PKG_CONFIG_FOUND)
  24. #
  25. ### Look for the include files.
  26. #
  27. find_path(
  28. MPV_INCLUDE_DIR
  29. NAMES mpv/client.h
  30. HINTS
  31. ${PC_MPV_INCLUDEDIR}
  32. ${PC_MPV_INCLUDE_DIRS} # Unused for MPV but anyway
  33. DOC "MPV include directory"
  34. )
  35. #
  36. ### Look for the libraries
  37. #
  38. set(_MPV_LIBRARY_NAMES mpv)
  39. if(PC_MPV_LIBRARIES)
  40. set(_MPV_LIBRARY_NAMES ${PC_MPV_LIBRARIES})
  41. endif(PC_MPV_LIBRARIES)
  42. foreach(l ${_MPV_LIBRARY_NAMES})
  43. find_library(
  44. MPV_LIBRARY_${l}
  45. NAMES ${l}
  46. HINTS
  47. ${PC_MPV_LIBDIR}
  48. ${PC_MPV_LIBRARY_DIRS} # Unused for MPV but anyway
  49. PATH_SUFFIXES lib${LIB_SUFFIX}
  50. )
  51. list(APPEND MPV_LIBRARY ${MPV_LIBRARY_${l}})
  52. endforeach()
  53. get_filename_component(_MPV_LIBRARY_DIR ${MPV_LIBRARY_mpv} PATH)
  54. mark_as_advanced(MPV_LIBRARY)
  55. set(MPV_LIBRARY_DIRS _MPV_LIBRARY_DIR)
  56. list(REMOVE_DUPLICATES MPV_LIBRARY_DIRS)
  57. mark_as_advanced(MPV_INCLUDE_DIR)
  58. mark_as_advanced(MPV_LIBRARY_DIRS)
  59. set(MPV_INCLUDE_DIRS ${MPV_INCLUDE_DIR})
  60. #
  61. ### Check if everything was found and if the version is sufficient.
  62. #
  63. include(FindPackageHandleStandardArgs)
  64. find_package_handle_standard_args(
  65. MPV
  66. REQUIRED_VARS ${_MPV_REQUIRED_VARS}
  67. VERSION_VAR MPV_VERSION_STRING
  68. )