@@ -71,30 +71,11 @@ function(make_torchcodec_sublibrary
7171 )
7272 endif ()
7373
74- # For the core library, make dependencies PRIVATE to prevent transitive linking issues
75- # but still expose include directories
76- if (${library_name} MATCHES ".*_core[0-9]+$" )
77- target_link_libraries (
78- ${library_name}
79- PRIVATE
80- ${library_dependencies}
81- )
82- # Manually expose FFmpeg include directories as PUBLIC for compilation
83- foreach (dep ${library_dependencies} )
84- if (TARGET ${dep} )
85- get_target_property (dep_include_dirs ${dep} INTERFACE_INCLUDE_DIRECTORIES )
86- if (dep_include_dirs)
87- target_include_directories (${library_name} PUBLIC ${dep_include_dirs} )
88- endif ()
89- endif ()
90- endforeach ()
91- else ()
92- target_link_libraries (
93- ${library_name}
94- PUBLIC
95- ${library_dependencies}
96- )
97- endif ()
74+ target_link_libraries (
75+ ${library_name}
76+ PUBLIC
77+ ${library_dependencies}
78+ )
9879
9980endfunction ()
10081
@@ -160,19 +141,32 @@ function(make_torchcodec_libraries
160141 AVIOTensorContext.cpp
161142 custom_ops.cpp
162143 )
163- set (custom_ops_dependencies
164- ${core_library_name}
165- ${Python3_LIBRARIES}
166- )
167- if (WIN32 )
168- list (APPEND custom_ops_dependencies Python3::Python)
144+ # On Windows, custom_ops should not transitively link to FFmpeg to avoid DLL issues
145+ if (WIN32 )
146+ set (custom_ops_dependencies
147+ ${Python3_LIBRARIES}
148+ Python3::Python
149+ )
150+ # Link to core library but without transitive dependencies
151+ set (custom_ops_core_dependency ${core_library_name} )
152+ else ()
153+ set (custom_ops_dependencies
154+ ${core_library_name}
155+ ${Python3_LIBRARIES}
156+ )
157+ set (custom_ops_core_dependency "" )
169158 endif ()
170159 make_torchcodec_sublibrary(
171160 "${custom_ops_library_name} "
172161 SHARED
173162 "${custom_ops_sources} "
174163 "${custom_ops_dependencies} "
175164 )
165+
166+ # On Windows, link to core library privately to avoid transitive FFmpeg dependencies
167+ if (WIN32 AND custom_ops_core_dependency)
168+ target_link_libraries (${custom_ops_library_name} PRIVATE ${custom_ops_core_dependency} )
169+ endif ()
176170
177171
178172 # 3. Create libtorchcodec_pybind_opsN.so.
0 commit comments