Skip to content

Commit

Permalink
fix(cmake): fix PyTorch_LIBRARY_PATH (#3890)
Browse files Browse the repository at this point in the history
The previous `PyTorch_LIBRARY_PATH` in #3636 is wrong:
`BACKEND_INCLUDE_DIRS` is a list of paths instead of a single path.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Improved the method for retrieving the PyTorch library path during the
build process to enhance configuration accuracy.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
njzjz authored Jun 21, 2024
1 parent 7a0ec5d commit f9d5f56
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,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()
Expand Down

0 comments on commit f9d5f56

Please sign in to comment.