FindMPEG.cmake 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file LICENSE.rst or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindMPEG
  5. --------
  6. Finds the native MPEG library (libmpeg2):
  7. .. code-block:: cmake
  8. find_package(MPEG [...])
  9. .. note::
  10. This module is functionally identical to the :module:`FindMPEG2` module, which
  11. also finds the libmpeg2 library. Both modules were introduced in the past to
  12. provide flexibility in handling potential differences in future versions of
  13. the MPEG library and to maintain backward compatibility across CMake releases.
  14. The ``FindMPEG2`` module additionally checks for the SDL dependency and
  15. includes it in its usage requirements. For working with libmpeg2, it is
  16. recommended to use the :module:`FindMPEG2` module instead of this one.
  17. Result Variables
  18. ^^^^^^^^^^^^^^^^
  19. This module defines the following variables:
  20. ``MPEG_FOUND``
  21. Boolean indicating whether the libmpeg2 library was found.
  22. ``MPEG_LIBRARIES``
  23. Libraries needed to link against to use libmpeg2.
  24. Cache Variables
  25. ^^^^^^^^^^^^^^^
  26. The following cache variables may also be set:
  27. ``MPEG_INCLUDE_DIR``
  28. The directory containing the ``mpeg2.h`` and related headers needed to use
  29. libmpeg2 library.
  30. ``MPEG_mpeg2_LIBRARY``
  31. The path to the libmpeg2 library.
  32. ``MPEG_vo_LIBRARY``
  33. The path to the vo (Video Out) library.
  34. Examples
  35. ^^^^^^^^
  36. Finding libmpeg2 library and creating an imported interface target for linking
  37. it to a project target:
  38. .. code-block:: cmake
  39. find_package(MPEG)
  40. if(MPEG_FOUND AND NOT TARGET MPEG::MPEG)
  41. add_library(MPEG::MPEG INTERFACE IMPORTED)
  42. set_target_properties(
  43. MPEG::MPEG
  44. PROPERTIES
  45. INTERFACE_LINK_LIBRARIES "${MPEG_LIBRARIES}"
  46. INTERFACE_INCLUDE_DIRECTORIES "${MPEG_INCLUDE_DIR}"
  47. )
  48. endif()
  49. target_link_libraries(project_target PRIVATE MPEG::MPEG)
  50. #]=======================================================================]
  51. find_path(MPEG_INCLUDE_DIR
  52. NAMES mpeg2.h mpeg2dec/mpeg2.h mpeg2dec/include/video_out.h)
  53. find_library(MPEG_mpeg2_LIBRARY mpeg2)
  54. find_library(MPEG_vo_LIBRARY vo)
  55. include(FindPackageHandleStandardArgs)
  56. find_package_handle_standard_args(MPEG DEFAULT_MSG MPEG_mpeg2_LIBRARY MPEG_INCLUDE_DIR)
  57. if(MPEG_FOUND)
  58. set( MPEG_LIBRARIES ${MPEG_mpeg2_LIBRARY} )
  59. if(MPEG_vo_LIBRARY)
  60. list(APPEND MPEG2_LIBRARIES ${MPEG_vo_LIBRARY})
  61. endif()
  62. endif()
  63. mark_as_advanced(MPEG_INCLUDE_DIR MPEG_mpeg2_LIBRARY MPEG_vo_LIBRARY)