vcpkg/ports/libtorch/fix-system-tensorpipe.patch

46 lines
2.0 KiB
Diff

--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1179,37 +1179,42 @@
if(MSVC)
message(WARNING "Tensorpipe cannot be used on Windows.")
else()
+ if(FALSE)
if(USE_CUDA)
set(TP_USE_CUDA ON CACHE BOOL "" FORCE)
set(TP_ENABLE_CUDA_IPC ON CACHE BOOL "" FORCE)
endif()
set(TP_BUILD_LIBUV ON CACHE BOOL "" FORCE)
add_compile_options(-DTORCH_USE_LIBUV)
include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/tensorpipe/third_party/libuv/include)
set(TP_STATIC_OR_SHARED STATIC CACHE STRING "" FORCE)
# Tensorpipe uses cuda_add_library
torch_update_find_cuda_flags()
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/tensorpipe)
# Suppress warning to unblock libnop compilation by clang-17
# See https://github.com/pytorch/pytorch/issues/151316
target_compile_options_if_supported(tensorpipe -Wno-missing-template-arg-list-after-template-kw)
# Workaround for relocation truncated to fit: R_AARCH64_CALL26 against symbol __aarch64_swp4_relax'
# When compiling for ARMv8.0, build uv with embedded atomics, which are slightly slower
# But are used only once during shutdown
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
target_compile_options_if_supported(tensorpipe_uv -mno-outline-atomics)
endif()
+ endif()
+ find_package(unofficial-tensorpipe CONFIG REQUIRED)
+ add_library(tensorpipe ALIAS unofficial::tensorpipe::tensorpipe)
list(APPEND Caffe2_DEPENDENCY_LIBS tensorpipe)
list(APPEND Caffe2_DEPENDENCY_LIBS nlohmann)
list(APPEND Caffe2_DEPENDENCY_LIBS moodycamel)
if(USE_CUDA)
+ add_library(tensorpipe_cuda ALIAS unofficial::tensorpipe::tensorpipe_cuda)
list(APPEND Caffe2_CUDA_DEPENDENCY_LIBS tensorpipe_cuda)
elseif(USE_ROCM)
message(WARNING "TensorPipe doesn't yet support ROCm")
# Not yet...
# list(APPEND Caffe2_HIP_DEPENDENCY_LIBS tensorpipe_hip)
endif()
endif()
endif()