FindMPV.cmake 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. SET(_MPV_REQUIRED_VARS MPV_INCLUDE_DIR MPV_LIBRARY)
  15. if(PKG_CONFIG_FOUND)
  16. pkg_check_modules(PC_MPV QUIET mpv)
  17. endif(PKG_CONFIG_FOUND)
  18. find_path(
  19. MPV_INCLUDE_DIR
  20. NAMES mpv/client.h
  21. HINTS
  22. ${PC_MPV_INCLUDEDIR}
  23. ${PC_MPV_INCLUDE_DIRS} # Unused for MPV but anyway
  24. DOC "MPV include directory"
  25. )
  26. set(_MPV_LIBRARY_NAMES mpv)
  27. if(PC_MPV_LIBRARIES)
  28. set(_MPV_LIBRARY_NAMES ${PC_MPV_LIBRARIES})
  29. endif(PC_MPV_LIBRARIES)
  30. foreach(l ${_MPV_LIBRARY_NAMES})
  31. find_library(
  32. MPV_LIBRARY_${l}
  33. NAMES ${l}
  34. HINTS
  35. ${PC_MPV_LIBDIR}
  36. ${PC_MPV_LIBRARY_DIRS} # Unused for MPV but anyway
  37. PATH_SUFFIXES lib${LIB_SUFFIX}
  38. )
  39. list(APPEND MPV_LIBRARY ${MPV_LIBRARY_${l}})
  40. endforeach()
  41. get_filename_component(_MPV_LIBRARY_DIR ${MPV_LIBRARY_mpv} PATH)
  42. mark_as_advanced(MPV_LIBRARY)
  43. set(MPV_LIBRARY_DIRS _MPV_LIBRARY_DIR)
  44. list(REMOVE_DUPLICATES MPV_LIBRARY_DIRS)
  45. mark_as_advanced(MPV_INCLUDE_DIR)
  46. mark_as_advanced(MPV_LIBRARY_DIRS)
  47. set(MPV_INCLUDE_DIRS ${MPV_INCLUDE_DIR})
  48. include(FindPackageHandleStandardArgs)
  49. find_package_handle_standard_args(
  50. MPV
  51. REQUIRED_VARS ${_MPV_REQUIRED_VARS}
  52. VERSION_VAR MPV_VERSION_STRING
  53. )
  54. if(MPV_FOUND)
  55. message(STATUS
  56. "Found MPV: ${MPV_LIBRARY}, ${MPV_INCLUDE_DIR}")
  57. endif()