1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-08 22:37:04 +08:00
CMake/Modules/FindMPEG.cmake
Peter Kokot cea6119266
FindMPEG, FindMPEG2: Update documentation
- Modules documentation updated and synced.
- Added examples section.
- FindMPEG and FindMPEG2 modules behave very much the same except that
  FindMPEG2 also adds the SDL library as a dependency. Added notes
  regarding this and recommended to use the FindMPEG2 as it also links
  in the SDL library at the time of writing.
2025-04-15 02:29:36 +02:00

85 lines
2.4 KiB
CMake

# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file LICENSE.rst or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindMPEG
--------
Finds the native MPEG library (libmpeg2).
.. note::
This module is functionally identical to the :module:`FindMPEG2` module, which
also finds the libmpeg2 library. Both modules were introduced in the past to
provide flexibility in handling potential differences in future versions of
the MPEG library and to maintain backward compatibility across CMake releases.
The ``FindMPEG2`` module additionally checks for the SDL dependency and
includes it in its usage requirements. For working with libmpeg2, it is
recommended to use the :module:`FindMPEG2` module instead of this one.
Result Variables
^^^^^^^^^^^^^^^^
This module defines the following variables:
``MPEG_FOUND``
Boolean indicating whether the libmpeg2 library is found.
``MPEG_LIBRARIES``
Libraries needed to link against to use libmpeg2.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may be also set:
``MPEG_INCLUDE_DIR``
The directory containing the ``mpeg2.h`` and related headers needed to use
libmpeg2 library.
``MPEG_mpeg2_LIBRARY``
The path to the libmpeg2 library.
``MPEG_vo_LIBRARY``
The path to the vo (Video Out) library.
Examples
^^^^^^^^
Finding libmpeg2 library and creating an imported interface target for linking
it to a project target:
.. code-block:: cmake
find_package(MPEG)
if(MPEG_FOUND AND NOT TARGET MPEG::MPEG)
add_library(MPEG::MPEG INTERFACE IMPORTED)
set_target_properties(
MPEG::MPEG
PROPERTIES
INTERFACE_LINK_LIBRARIES "${MPEG_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${MPEG_INCLUDE_DIR}"
)
endif()
target_link_libraries(project_target PRIVATE MPEG::MPEG)
#]=======================================================================]
find_path(MPEG_INCLUDE_DIR
NAMES mpeg2.h mpeg2dec/mpeg2.h mpeg2dec/include/video_out.h)
find_library(MPEG_mpeg2_LIBRARY mpeg2)
find_library(MPEG_vo_LIBRARY vo)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MPEG DEFAULT_MSG MPEG_mpeg2_LIBRARY MPEG_INCLUDE_DIR)
if(MPEG_FOUND)
set( MPEG_LIBRARIES ${MPEG_mpeg2_LIBRARY} )
if(MPEG_vo_LIBRARY)
list(APPEND MPEG2_LIBRARIES ${MPEG_vo_LIBRARY})
endif()
endif()
mark_as_advanced(MPEG_INCLUDE_DIR MPEG_mpeg2_LIBRARY MPEG_vo_LIBRARY)