forked from clementfarabet/lua---nnx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
132 lines (111 loc) · 5.16 KB
/
CMakeLists.txt
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
cmake_minimum_required(VERSION 2.8)
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
IF(${CMAKE_PROJECT_NAME} STREQUAL "Torch")
SET(TORCH_LIBRARIES TH luaT)
SET(TORCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(TORCH_TH TH)
SET(TORCH_luaT luaT)
SET(INSTALL_PREFIX /${Torch_INSTALL_LUA_PATH_SUBDIR}/nnx)
SET(CINSTALL_PREFIX /${Torch_INSTALL_LUA_CPATH_SUBDIR})
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
SET(LIBS ${TORCH_LIBRARIES} ${LUA_LIBRARIES})
ELSE(${CMAKE_PROJECT_NAME} STREQUAL "Torch")
# infer path for Torch7
string (REGEX REPLACE "(.*)lib/luarocks/rocks.*" "\\1" TORCH_PREFIX "${CMAKE_INSTALL_PREFIX}" )
message (STATUS "Found Torch7, installed in: " ${TORCH_PREFIX})
find_package (Torch REQUIRED)
SET(INSTALL_PREFIX /lua/nnx)
SET(CINSTALL_PREFIX /lib)
ENDIF(${CMAKE_PROJECT_NAME} STREQUAL "Torch")
find_package (OpenMP REQUIRED)
if (OPENMP_FOUND)
message (STATUS "OpenMP Found with compiler flag : ${OpenMP_C_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
endif (OPENMP_FOUND)
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
include_directories (${TORCH_INCLUDE_DIR} ${PROJECT_SOURCE_DIR})
SET(WITH_CUDA OFF CACHE BOOL "Compile qlua and associated packages")
IF(EXISTS "${TORCH_BIN_DIR}/../include/THC/THC.h")
FIND_PACKAGE(CUDA 4.0)
ENDIF(EXISTS "${TORCH_BIN_DIR}/../include/THC/THC.h")
IF (CUDA_FOUND)
# bug on Apple
IF(APPLE)
LINK_DIRECTORIES("/usr/local/cuda/lib/")
ENDIF(APPLE)
find_library (TORCH_THC THC ${TORCH_BIN_DIR}/../lib NO_DEFAULT_PATH)
set (TORCH_LIBRARIES ${TORCH_TH} ${TORCH_THC} ${TORCH_luaT} ${TORCH_lua})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_CUDA")
cuda_add_library (lbfgs SHARED lbfgs.c)
target_link_libraries (lbfgs ${TORCH_LIBRARIES})
CUDA_ADD_CUBLAS_TO_TARGET(lbfgs)
install_targets (${CINSTALL_PREFIX} lbfgs)
ELSE (CUDA_FOUND)
MESSAGE(STATUS "Disabling CUDA (CUDA 4.0 required, and not found)")
MESSAGE(STATUS "If CUDA 4.0 is installed, then specify CUDA_TOOLKIT_ROOT_DIR")
set (TORCH_LIBRARIES ${TORCH_TH} ${TORCH_luaT} ${TORCH_lua})
add_library (lbfgs SHARED lbfgs.c)
target_link_libraries (lbfgs ${TORCH_LIBRARIES})
install_targets (${CINSTALL_PREFIX} lbfgs)
ENDIF (CUDA_FOUND)
include_directories (${TORCH_INCLUDE_DIR} ${PROJECT_SOURCE_DIR})
add_library (nnx SHARED init.c)
link_directories (${TORCH_LIBRARY_DIR})
target_link_libraries (nnx ${TORCH_LIBRARIES})
install_files(${INSTALL_PREFIX} init.lua)
install_files(${INSTALL_PREFIX} Abs.lua)
install_files(${INSTALL_PREFIX} ConfusionMatrix.lua)
install_files(${INSTALL_PREFIX} DistNLLCriterion.lua)
install_files(${INSTALL_PREFIX} KLDivCriterion.lua)
install_files(${INSTALL_PREFIX} DistMarginCriterion.lua)
install_files(${INSTALL_PREFIX} Logger.lua)
install_files(${INSTALL_PREFIX} Probe.lua)
install_files(${INSTALL_PREFIX} HardShrink.lua)
install_files(${INSTALL_PREFIX} Narrow.lua)
install_files(${INSTALL_PREFIX} Type.lua)
install_files(${INSTALL_PREFIX} Power.lua)
install_files(${INSTALL_PREFIX} Square.lua)
install_files(${INSTALL_PREFIX} Sqrt.lua)
install_files(${INSTALL_PREFIX} Threshold.lua)
install_files(${INSTALL_PREFIX} OmpModule.lua)
install_files(${INSTALL_PREFIX} SpatialClassifier.lua)
install_files(${INSTALL_PREFIX} SpatialMaxSampling.lua)
install_files(${INSTALL_PREFIX} SpatialLinear.lua)
install_files(${INSTALL_PREFIX} SpatialPadding.lua)
install_files(${INSTALL_PREFIX} SpatialNormalization.lua)
install_files(${INSTALL_PREFIX} SpatialUpSampling.lua)
install_files(${INSTALL_PREFIX} SpatialReSampling.lua)
install_files(${INSTALL_PREFIX} SpatialConvolutionSparse.lua)
install_files(${INSTALL_PREFIX} SuperCriterion.lua)
install_files(${INSTALL_PREFIX} SpatialCriterion.lua)
install_files(${INSTALL_PREFIX} Trainer.lua)
install_files(${INSTALL_PREFIX} OnlineTrainer.lua)
install_files(${INSTALL_PREFIX} DataSet.lua)
install_files(${INSTALL_PREFIX} DataList.lua)
install_files(${INSTALL_PREFIX} DataSetLabelMe.lua)
install_files(${INSTALL_PREFIX} CMulTable.lua)
install_files(${INSTALL_PREFIX} CAddTable.lua)
install_files(${INSTALL_PREFIX} CDivTable.lua)
install_files(${INSTALL_PREFIX} CSubTable.lua)
install_files(${INSTALL_PREFIX} Replicate.lua)
install_files(${INSTALL_PREFIX} SpatialFovea.lua)
install_files(${INSTALL_PREFIX} SpatialMSECriterion.lua)
install_files(${INSTALL_PREFIX} SpatialClassNLLCriterion.lua)
install_files(${INSTALL_PREFIX} SparseCriterion.lua)
install_files(${INSTALL_PREFIX} SpatialSparseCriterion.lua)
install_files(${INSTALL_PREFIX} SpatialGraph.lua)
install_files(${INSTALL_PREFIX} SpatialColorTransform.lua)
install_files(${INSTALL_PREFIX} SpatialRecursiveFovea.lua)
install_files(${INSTALL_PREFIX} Optimization.lua)
install_files(${INSTALL_PREFIX} LBFGSOptimization.lua)
install_files(${INSTALL_PREFIX} CGOptimization.lua)
install_files(${INSTALL_PREFIX} newCGOptimization.lua)
install_files(${INSTALL_PREFIX} SGDOptimization.lua)
install_files(${INSTALL_PREFIX} ASGDOptimization.lua)
install_files(${INSTALL_PREFIX} GeneticSGDOptimization.lua)
install_files(${INSTALL_PREFIX} BatchOptimization.lua)
install_files(${INSTALL_PREFIX} SNESOptimization.lua)
install_files(${INSTALL_PREFIX} DiagHessian.lua)
install_files(${INSTALL_PREFIX} BatchTrainer.lua)
add_subdirectory (test)
install_targets(${CINSTALL_PREFIX} nnx)