forked from VowpalWabbit/vowpal_wabbit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindTorch.cmake
71 lines (57 loc) · 2.03 KB
/
FindTorch.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Find Torch (luaT+TH)
if (TORCH_PREFIX)
find_program (TORCH_EXECUTABLE lua ${TORCH_PREFIX}/bin NO_DEFAULT_PATH)
endif (TORCH_PREFIX)
if (NOT TORCH_EXECUTABLE)
find_program (TORCH_EXECUTABLE lua PATH)
endif (NOT TORCH_EXECUTABLE)
if (TORCH_EXECUTABLE)
get_filename_component (TORCH_BIN_DIR ${TORCH_EXECUTABLE} PATH)
endif (TORCH_EXECUTABLE)
find_library (TORCH_TH TH ${TORCH_BIN_DIR}/../lib NO_DEFAULT_PATH)
find_library (TORCH_luaT luaT ${TORCH_BIN_DIR}/../lib NO_DEFAULT_PATH)
find_library (TORCH_lua lua ${TORCH_BIN_DIR}/../lib NO_DEFAULT_PATH)
set (TORCH_LIBRARIES ${TORCH_TH} ${TORCH_luaT} ${TORCH_lua})
find_path (TORCH_INCLUDE_DIR lua.h
${TORCH_BIN_DIR}/../include/
NO_DEFAULT_PATH)
set (TORCH_INCLUDE_DIR ${TORCH_INCLUDE_DIR} ${TORCH_INCLUDE_DIR}/TH)
set (TORCH_PACKAGE_PATH "${TORCH_BIN_DIR}/../share/lua/5.1" CACHE PATH "where Lua searches for Lua packages")
set (TORCH_PACKAGE_CPATH "${TORCH_BIN_DIR}/../lib/lua/5.1" CACHE PATH "where Lua searches for library packages")
set (TORCH_PREFIX ${TORCH_BIN_DIR}/..)
mark_as_advanced (
TORCH_PREFIX
TORCH_EXECUTABLE
TORCH_LIBRARIES
TORCH_INCLUDE_DIR
TORCH_PACKAGE_PATH
TORCH_PACKAGE_CPATH
)
set (TORCH_FOUND 1)
if (NOT TORCH_TH)
set (TORCH_FOUND 0)
endif (NOT TORCH_TH)
if (NOT TORCH_lua)
set (TORCH_FOUND 0)
endif (NOT TORCH_lua)
if (NOT TORCH_luaT)
set (TORCH_FOUND 0)
endif (NOT TORCH_luaT)
if (NOT TORCH_EXECUTABLE)
set (TORCH_FOUND 0)
endif (NOT TORCH_EXECUTABLE)
if (NOT TORCH_INCLUDE_DIR)
set (TORCH_FOUND 0)
endif (NOT TORCH_INCLUDE_DIR)
if (NOT TORCH_FOUND AND Lua_FIND_REQUIRED)
message (FATAL_ERROR "Could not find Torch/Lua -- please install it!")
elseif (NOT TORCH_FOUND AND Lua_FIND_REQUIRED)
message (STATUS "Lua bin found in " ${TORCH_BIN_DIR})
endif (NOT TORCH_FOUND AND Lua_FIND_REQUIRED)
if (NOT Lua_FIND_QUIETLY)
if (TORCH_FOUND)
message (STATUS "Lua bin found in " ${TORCH_BIN_DIR})
else (TORCH_FOUND)
message (STATUS "Lua bin not found. Please specify location")
endif (TORCH_FOUND)
endif (NOT Lua_FIND_QUIETLY)