1- # TorchCodec supports 2 building scenarios in the respect to compatibility with
2- # FFmpeg:
3- #
4- # * Building against single FFmpeg version. In this case FFmpeg libraries can
5- # be detected by standard pkg-config approach.
6- # * Building against multiple FFmpeg versions at once. In this case the goal is
7- # to build few shared libraries each compatible with specific FFmpeg version.
8- # At runtime TochCodec will check current environment and select compatible
9- # build of the shared library.
10- #
11- # This file contains helper definitions and functions to expose CMake FFmpeg
12- # targets for both scenarios described above. File defines:
13- #
14- # `TORCHCODEC_SUPPORTED_FFMPEG_VERSIONS`
15- # CMake list of all FFmpeg major versions supported by TorchCodec. Note that
16- # this is a list of FFmpeg versions known to TorchCodec rather than a list
17- # of FFmpeg versions available on the current system.
18- #
19- # `add_ffmpeg_target(ffmpeg_major_version prefix)`
20- # * ffmpeg_major_version - FFmpeg major version for which CMake target needs
21- # to be defined
22- # * prefix - Path to the FFmpeg installation folder
23- #
24- # This function checks that required FFmpeg objects (includes and libraries)
25- # are actually available and defines the following target:
26- # * `torchcodec::ffmpeg{$ffmpeg_major_version}`
27- #
28- # `add_ffmpeg_target_with_pkg_config(ret_ffmpeg_major_version_var)`
29- # * `ret_ffmpeg_major_version_var` - parent scope variable where function
30- # will return major version of ffmpeg which was found
31- #
32- # This function searches for the FFmpeg with pkg-config and defines the
33- # following target:
34- # * `torchcodec::ffmpeg{$ffmpeg_major_version}`
35- # where `$ffmpeg_major_version` as major version of the detected FFmpeg.
1+ # This file exposes helpers to create and expose FFmpeg targets as torchcodec::ffmpeg${N}
2+ # where N is the FFmpeg major version.
363
37- # All FFmpeg major versions supported by TorchCodec.
4+ # List of FFmpeg versions that TorchCodec can support - that's not a list of
5+ # FFmpeg versions available on the current system!
386set (TORCHCODEC_SUPPORTED_FFMPEG_VERSIONS "4;5;6;7;8" )
397
408# Below we define FFmpeg library names we expect to have for each FFmpeg
@@ -201,8 +169,8 @@ endif()
201169
202170# Create and expose torchcodec::ffmpeg${ffmpeg_major_version} target which can
203171# then be used as a dependency in other targets.
204- # prefix must be the path to the FFmpeg installation containing the usual
205- # `include` and `lib` directories.
172+ # prefix is the path to the FFmpeg installation containing the usual `include`
173+ # and `lib` directories.
206174function (add_ffmpeg_target ffmpeg_major_version prefix )
207175 # Check that given ffmpeg major version is something we support and error out if
208176 # it's not.
@@ -244,6 +212,9 @@ function(add_ffmpeg_target ffmpeg_major_version prefix)
244212 target_link_libraries (${target} INTERFACE ${lib_paths} )
245213endfunction ()
246214
215+ # Create and expose torchcodec::ffmpeg${ffmpeg_major_version} target which can
216+ # then be used as a dependency in other targets.
217+ # The FFmpeg installation is found by pkg-config.
247218function (add_ffmpeg_target_with_pkg_config ret_ffmpeg_major_version_var)
248219 find_package (PkgConfig REQUIRED)
249220 pkg_check_modules(TORCHCODEC_LIBAV REQUIRED IMPORTED_TARGET
@@ -257,6 +228,7 @@ function(add_ffmpeg_target_with_pkg_config ret_ffmpeg_major_version_var)
257228 )
258229
259230 # Split libavcodec's version string by '.' and convert it to a list
231+ # The TORCHCODEC_LIBAV_libavcodec_VERSION is made available by pkg-config.
260232 string (REPLACE "." ";" libavcodec_version_list ${TORCHCODEC_LIBAV_libavcodec_VERSION} )
261233 # Get the first element of the list, which is the major version
262234 list (GET libavcodec_version_list 0 libavcodec_major_version)
0 commit comments