FindMPV.cmake 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. if(NOT WIN32)
  43. foreach(l ${_MPV_LIBRARY_NAMES})
  44. find_library(
  45. MPV_LIBRARY_${l}
  46. NAMES ${l}
  47. HINTS
  48. ${PC_MPV_LIBDIR}
  49. ${PC_MPV_LIBRARY_DIRS} # Unused for MPV but anyway
  50. PATH_SUFFIXES lib${LIB_SUFFIX}
  51. )
  52. list(APPEND MPV_LIBRARY ${MPV_LIBRARY_${l}})
  53. endforeach()
  54. get_filename_component(_MPV_LIBRARY_DIR ${MPV_LIBRARY_mpv} PATH)
  55. mark_as_advanced(MPV_LIBRARY)
  56. endif(NOT WIN32)
  57. set(MPV_LIBRARY_DIRS _MPV_LIBRARY_DIR)
  58. list(REMOVE_DUPLICATES MPV_LIBRARY_DIRS)
  59. mark_as_advanced(MPV_INCLUDE_DIR)
  60. mark_as_advanced(MPV_LIBRARY_DIRS)
  61. set(MPV_INCLUDE_DIRS ${MPV_INCLUDE_DIR})
  62. #
  63. ### Check if everything was found and if the version is sufficient.
  64. #
  65. include(FindPackageHandleStandardArgs)
  66. find_package_handle_standard_args(
  67. MPV
  68. REQUIRED_VARS ${_MPV_REQUIRED_VARS}
  69. VERSION_VAR MPV_VERSION_STRING
  70. )