Skip to content

Commit 0b1ec27

Browse files
committed
Nits
1 parent 3129f7e commit 0b1ec27

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/torchcodec/share/cmake/TorchCodec/ffmpeg_versions.cmake

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ else()
199199
)
200200
endif()
201201

202+
# Create and expose torchcodec::ffmpeg${ffmpeg_major_version} target which can
203+
# 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.
202206
function(add_ffmpeg_target ffmpeg_major_version prefix)
203207
# Check that given ffmpeg major version is something we support and error out if
204208
# it's not.
@@ -211,32 +215,32 @@ function(add_ffmpeg_target ffmpeg_major_version prefix)
211215
endif()
212216

213217
set(target "torchcodec::ffmpeg${ffmpeg_major_version}")
214-
set(incdir "${prefix}/include")
218+
set(include_dir "${prefix}/include")
215219
if (LINUX OR APPLE)
216-
set(libdir "${prefix}/lib")
220+
set(lib_dir "${prefix}/lib")
217221
elseif (WIN32)
218-
set(libdir "${prefix}/bin")
222+
set(lib_dir "${prefix}/bin")
219223
else()
220224
message(FATAL_ERROR "Unsupported operating system: ${CMAKE_SYSTEM_NAME}")
221225
endif()
222226

223227
list(
224228
TRANSFORM f${ffmpeg_major_version}_library_file_names
225-
PREPEND ${libdir}/
229+
PREPEND ${lib_dir}/
226230
OUTPUT_VARIABLE lib_paths
227231
)
228232

229233
message("Adding ${target} target")
230234
# Verify that ffmpeg includes and libraries actually exist.
231-
foreach (path IN LISTS incdir lib_paths)
235+
foreach (path IN LISTS include_dir lib_paths)
232236
if (NOT EXISTS "${path}")
233237
message(FATAL_ERROR "${path} does not exist")
234238
endif()
235239
endforeach()
236240

237241
# Actually define the target
238242
add_library(${target} INTERFACE IMPORTED)
239-
target_include_directories(${target} INTERFACE ${incdir})
243+
target_include_directories(${target} INTERFACE ${include_dir})
240244
target_link_libraries(${target} INTERFACE ${lib_paths})
241245
endfunction()
242246

0 commit comments

Comments
 (0)