Skip to content

Commit 60df908

Browse files
committed
Revert "OK at this point I have no idea"
This reverts commit d896211.
1 parent 01f9dc0 commit 60df908

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

src/torchcodec/_core/CMakeLists.txt

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,30 @@ function(make_torchcodec_sublibrary
7171
)
7272
endif()
7373

74-
target_link_libraries(
75-
${library_name}
76-
PUBLIC
77-
${library_dependencies}
78-
)
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()
7998

8099
endfunction()
81100

@@ -141,32 +160,19 @@ function(make_torchcodec_libraries
141160
AVIOTensorContext.cpp
142161
custom_ops.cpp
143162
)
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 "")
163+
set(custom_ops_dependencies
164+
${core_library_name}
165+
${Python3_LIBRARIES}
166+
)
167+
if (WIN32)
168+
list(APPEND custom_ops_dependencies Python3::Python)
158169
endif()
159170
make_torchcodec_sublibrary(
160171
"${custom_ops_library_name}"
161172
SHARED
162173
"${custom_ops_sources}"
163174
"${custom_ops_dependencies}"
164175
)
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()
170176

171177

172178
# 3. Create libtorchcodec_pybind_opsN.so.

0 commit comments

Comments
 (0)