FindMPV.cmake 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. if(PC_MPV_FOUND)
  25. #
  26. ### Look for the include files.
  27. #
  28. find_path(
  29. MPV_INCLUDE_DIR
  30. NAMES mpv/client.h
  31. HINTS
  32. ${PC_MPV_INCLUDEDIR}
  33. ${PC_MPV_INCLUDE_DIRS} # Unused for MPV but anyway
  34. DOC "MPV include directory"
  35. )
  36. #
  37. ### Look for the libraries
  38. #
  39. set(_MPV_LIBRARY_NAMES mpv)
  40. if(PC_MPV_LIBRARIES)
  41. set(_MPV_LIBRARY_NAMES ${PC_MPV_LIBRARIES})
  42. endif(PC_MPV_LIBRARIES)
  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. set(MPV_LIBRARY_DIRS _MPV_LIBRARY_DIR)
  57. list(REMOVE_DUPLICATES MPV_LIBRARY_DIRS)
  58. endif()
  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. )