From 6d150abb28ba46a815aeb047deda30f14ec0f3a3 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 20 Jun 2024 16:55:27 -0400 Subject: [PATCH] fix(cmake): fix PyTorch_LIBRARY_PATH The previous `PyTorch_LIBRARY_PATH` in #3636 is wrong: `BACKEND_INCLUDE_DIRS` is a list of paths instead of a single path. Signed-off-by: Jinzhe Zeng --- source/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 105a7c2695..bb9ccf8f4e 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -199,8 +199,9 @@ if(ENABLE_PYTORCH AND NOT DEEPMD_C_ROOT) add_definitions(-D_GLIBCXX_USE_CXX11_ABI=${OP_CXX_ABI}) endif() endif() - # get torch directory - set(PyTorch_LIBRARY_PATH ${TORCH_INCLUDE_DIRS}/../lib) + # get torch directory get the directory of the target "torch" + get_target_property(_TORCH_LOCATION torch LOCATION) + get_filename_component(PyTorch_LIBRARY_PATH ${_TORCH_LOCATION} DIRECTORY) list(APPEND BACKEND_LIBRARY_PATH ${PyTorch_LIBRARY_PATH}) list(APPEND BACKEND_INCLUDE_DIRS ${TORCH_INCLUDE_DIRS}) endif()