-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
141 lines (118 loc) · 2.92 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
133
134
135
136
137
138
139
# This CMakeLists.txt file can be used to generate makefiles for several projects at once.
# It should be put in the directory containing the projects.
cmake_minimum_required(VERSION 2.8)
set(CUDNN_PATH ~/cuDNN/cudnn-7.0-linux-x64-v3 CACHE PATH "Location of cuDNN libraries")
set(GTEST_PATH ~/gtest/gtest-1.7.0 CACHE PATH "Location of gtest library")
set(MATIO_PATH ~/matio/build CACHE PATH "Location of matio library")
set(CIMG_PATH ~/cimg/CImg-1.6.8_pre102815/ CACHE PATH "Location of cimg library")
#Set output bin directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/)
find_package(CUDA QUIET REQUIRED)
#Set various cuda flags
#NOTE the arch used here is for a gtx 960, which is in the machien sisters.
#Change arch type as need be
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -arch=sm_52;)
set(CMAKE_CXX_FLAGS "-W -Wall -Wno-unused-parameter -Wno-unused-variable")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -Xptxas; -v; -keep; -lineinfo; -g; -G;)
else (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -O;)
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
include_directories(
src
${CUDNN_PATH}/include
${GTEST_PATH}/include
${MATIO_PATH}/include
${CIMG_PATH}
${CMAKE_CURRENT_SOURCE_DIR}
)
link_directories(
${CUDNN_PATH}/lib64
${GTEST_PATH}
${MATIO_PATH}/lib
)
#Get all files with extensions in the src directory
file(GLOB tmp src/*.[ch]pp)
set(LibSrc ${LibSrc} ${tmp})
file(GLOB tmp src/*.cu)
set(LibSrc ${LibSrc} ${tmp})
file(GLOB tmp src/layers/*.[ch]pp)
set(LibSrc ${LibSrc} ${tmp})
file(GLOB tmp src/layers/*.cu)
set(LibSrc ${LibSrc} ${tmp})
file(GLOB tmp src/connections/*.[ch]pp)
set(LibSrc ${LibSrc} ${tmp})
file(GLOB tmp src/connections/*.cu)
set(LibSrc ${LibSrc} ${tmp})
file(GLOB testLibSrc tests/*.[ch]pp)
##Add compilation files to NVCC
#cuda_add_executable(
# depthMLP
# ${libSrcCPP}
# ${libSrcHPP}
# ${libSrcCU}
#)
#target_link_libraries(
# depthMLP
# -lcudnn
#)
#Add to library
cuda_add_library(
deepcnn
${LibSrc}
)
#Add compilation files to testing suite
cuda_add_executable(
test
${testLibSrc}
)
#Link libraries
target_link_libraries(
test
deepcnn
-lcudnn
-lgtest
-lpthread
-lmatio
)
#Add compilation files to testing suite
cuda_add_executable(
trainCifar
sims/trainCifar.cpp
)
target_link_libraries(
trainCifar
deepcnn
-lcudnn
-lgtest
-lpthread
-lmatio
)
#Add compilation files to testing suite
cuda_add_executable(
testCifar
sims/testCifar.cpp
)
target_link_libraries(
testCifar
deepcnn
-lcudnn
-lgtest
-lpthread
-lmatio
)
#Add compilation files to testing suite
cuda_add_executable(
testCifar_io
sims/testCifar_io.cpp
)
target_link_libraries(
testCifar_io
deepcnn
-lcudnn
-lgtest
-lpthread
-lmatio
)