diff --git a/Modules/FindMPEG.cmake b/Modules/FindMPEG.cmake index 26f8be4794..6c49702a14 100644 --- a/Modules/FindMPEG.cmake +++ b/Modules/FindMPEG.cmake @@ -5,22 +5,63 @@ FindMPEG -------- -Find the native MPEG includes and library +Finds the native MPEG library (libmpeg2). -This module defines +.. 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. - MPEG_INCLUDE_DIR, where to find MPEG.h, etc. - MPEG_LIBRARIES, the libraries required to use MPEG. - MPEG_FOUND, If false, do not try to use MPEG. + 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. -also defined, but not for general use are +Result Variables +^^^^^^^^^^^^^^^^ -:: +This module defines the following variables: - MPEG_mpeg2_LIBRARY, where to find the MPEG library. - MPEG_vo_LIBRARY, where to find the vo library. +``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 diff --git a/Modules/FindMPEG2.cmake b/Modules/FindMPEG2.cmake index 66a0ed04f3..103f2c49d1 100644 --- a/Modules/FindMPEG2.cmake +++ b/Modules/FindMPEG2.cmake @@ -5,22 +5,58 @@ FindMPEG2 --------- -Find the native MPEG2 includes and library +Finds the native MPEG2 library (libmpeg2). -This module defines +.. note:: -:: + Depending on how the native libmpeg2 library is built and installed, it may + depend on the SDL (Simple DirectMedia Layer) library. If SDL is found, this + module includes it in its usage requirements when used. - MPEG2_INCLUDE_DIR, path to mpeg2dec/mpeg2.h, etc. - MPEG2_LIBRARIES, the libraries required to use MPEG2. - MPEG2_FOUND, If false, do not try to use MPEG2. +Result Variables +^^^^^^^^^^^^^^^^ -also defined, but not for general use are +This module defines the following variables: -:: +``MPEG2_FOUND`` + Boolean indicating whether the libmpeg2 library is found. +``MPEG2_LIBRARIES`` + Libraries needed to link against to use libmpeg2. - MPEG2_mpeg2_LIBRARY, where to find the MPEG2 library. - MPEG2_vo_LIBRARY, where to find the vo library. +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may be also set: + +``MPEG2_INCLUDE_DIR`` + The directory containing the ``mpeg2.h`` and related headers needed to use + libmpeg2 library. +``MPEG2_mpeg2_LIBRARY`` + The path to the libmpeg2 library. +``MPEG2_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(MPEG2) + + if(MPEG2_FOUND AND NOT TARGET MPEG2::MPEG2) + add_library(MPEG2::MPEG2 INTERFACE IMPORTED) + set_target_properties( + MPEG2::MPEG2 + PROPERTIES + INTERFACE_LINK_LIBRARIES "${MPEG2_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${MPEG2_INCLUDE_DIR}" + ) + endif() + + target_link_libraries(project_target PRIVATE MPEG2::MPEG2) #]=======================================================================] find_path(MPEG2_INCLUDE_DIR @@ -39,8 +75,7 @@ if(MPEG2_FOUND) list(APPEND MPEG2_LIBRARIES ${MPEG2_vo_LIBRARY}) endif() - #some native mpeg2 installations will depend - #on libSDL, if found, add it in. + # Some native mpeg2 installations will depend on libSDL. If found, add it in. find_package(SDL) if(SDL_FOUND) set( MPEG2_LIBRARIES ${MPEG2_LIBRARIES} ${SDL_LIBRARY})