"vscode:/vscode.git/clone" did not exist on "da7e3994ad3408031113ef661650c625320d30cf"
FindTorch.cmake 1.57 KB
Newer Older
Hang Zhang's avatar
init  
Hang Zhang committed
1
2
3
4
5
6
7
8
9
10
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Hang Zhang
## ECE Department, Rutgers University
## Email: zhang.hang@rutgers.edu
## Copyright (c) 2017
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the root directory of this source tree 
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Hang Zhang's avatar
Hang Zhang committed
11
12
# No longer using manual way to find the library.
if(FALSE)
Hang Zhang's avatar
init  
Hang Zhang committed
13
14
15
FILE(GLOB TORCH_LIB_HINTS 
	"/anaconda/lib/python3.6/site-packages/torch/lib" 
	"/anaconda2/lib/python3.6/site-packages/torch/lib" 
Hang Zhang's avatar
Hang Zhang committed
16
17
	"$ENV{HOME}/anaconda/lib/python2.7/site-packages/torch/lib"
	"$ENV{HOME}/anaconda2/lib/python2.7/site-packages/torch/lib"
Hang Zhang's avatar
init  
Hang Zhang committed
18
19
20
21
22
)
FIND_PATH(TORCH_BUILD_DIR
	NAMES "THNN.h"
	PATHS "${TORCH_LIB_HINTS}"
)
Hang Zhang's avatar
Hang Zhang committed
23
24
25
FIND_LIBRARY(THC_LIBRARIES NAMES THC THC.1 PATHS ${TORCH_BUILD_DIR} PATH_SUFFIXES lib)
FIND_LIBRARY(TH_LIBRARIES NAMES TH TH.1 PATHS ${TORCH_BUILD_DIR} PATH_SUFFIXES lib)
endif()
Hang Zhang's avatar
init  
Hang Zhang committed
26

Hang Zhang's avatar
Hang Zhang committed
27
28
# Set the envrionment variable via python
SET(TORCH_BUILD_DIR "$ENV{TORCH_BUILD_DIR}")
Hang Zhang's avatar
init  
Hang Zhang committed
29
30
31
32
33
34
35
36
37
38
MESSAGE(STATUS "TORCH_BUILD_DIR: " ${TORCH_BUILD_DIR})

# Find the include files
SET(TORCH_TH_INCLUDE_DIR "${TORCH_BUILD_DIR}/include/TH")
SET(TORCH_THC_INCLUDE_DIR "${TORCH_BUILD_DIR}/include/THC")
SET(TORCH_THC_UTILS_INCLUDE_DIR "$ENV{HOME}/pytorch/torch/lib/THC")

SET(Torch_INSTALL_INCLUDE "${TORCH_BUILD_DIR}/include" ${TORCH_TH_INCLUDE_DIR} ${TORCH_THC_INCLUDE_DIR} ${TORCH_THC_UTILS_INCLUDE_DIR})

# Find the libs. We need to find libraries one by one.
Hang Zhang's avatar
Hang Zhang committed
39
40
SET(TH_LIBRARIES "$ENV{TH_LIBRARIES}")
SET(THC_LIBRARIES "$ENV{THC_LIBRARIES}")