-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
168 lines (148 loc) · 4.38 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
cmake_minimum_required(VERSION 2.8)
PROJECT (CvConvolutionalNet)
# IF() ENDIF() statements
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
# Specify build-type as Debug if not specified already
#IF (NOT CMAKE_BUILD_TYPE)
# SET(CMAKE_BUILD_TYPE Debug)
SET(CMAKE_BUILD_TYPE Release)
#ENDIF ()
# Produce verbose makefiles
# SET(CMAKE_VERBOSE_MAKEFILE ON)
# Sources for library
SET(CVCONVNET_SRCS
src/cvconvnet.cpp
src/cvconvnetparser.cpp
src/cvconvolutionplane.cpp
src/cvfastsigmoid.cpp
src/cvgenericplane.cpp
src/cvmaxoperatorplane.cpp
src/cvmaxplane.cpp
src/cvrbfplane.cpp
src/cvregressionplane.cpp
src/cvsubsamplingplane.cpp
src/cvsourceplane.cpp
)
# Sources for tests
SET(TEST_SRCS
test/cvmaxoperatorplane_test.cpp
)
# Sources for example files
SET (EXAMPLEIMG_SRCS example/testimg.cpp)
SET (EXAMPLEMNIST_SRCS example/testmnist.cpp)
SET (FEXAMPLEIMG_SRCS fexample/ftestimg.cpp)
SET (FACEDETECT_SRCS
fexample/facedetect.cpp
fexample/cnn.cpp)
# Ouptut directory for binaries
SET (EXECUTABLE_DIR bin)
# Here are common paths (in addition to default paths)
SET (INCLUDE_SEARCH_PATH
/usr/local/include
/usr/include
/usr/local/include/boost
/usr/local/include/opencv/
/usr/include/opencv/
/usr/local/include/opencv2/
c:/program\ files/opencv/include
/usr/lib/jvm/default-java/include
/usr/lib/jvm/default-java/include/linux
)
SET (LIBRARY_SEARCH_PATH
/usr/lib/
/usr/local/lib/
)
# Find OpenCV and Expat
FIND_PATH(CV_H NAMES cv.h PATHS ${INCLUDE_SEARCH_PATH} )
FIND_PATH(HIGHGUI_H NAMES highgui.h PATHS ${INCLUDE_SEARCH_PATH} )
FIND_PATH(EXPAT_H NAMES expat.h PATHS ${INCLUDE_SEARCH_PATH} )
FIND_PATH(JNI_H NAMES jni.h PATHS ${INCLUDE_SEARCH_PATH} )
FIND_PATH(JNI_MD_H NAMES jni_m.h PATHS ${INCLUDE_SEARCH_PATH} )
# Boost
FIND_PATH(BOOST_H NAMES unit_test.h PATHS ${INCLUDE_SEARCH_PATH} )
FIND_LIBRARY(LIBCV NAMES libopencv_core.so PATHS ${LIBRARY_SEARCH_PATH} )
FIND_LIBRARY(LIBHIGHGUI NAMES libopencv_highgui.so PATHS ${LIBRARY_SEARCH_PATH})
FIND_LIBRARY(LIBEXPAT NAMES expat PATHS ${LIBRARY_SEARCH_PATH} )
FIND_LIBRARY(LIBOBJDETECT NAMES libopencv_objdetect.so PATHS ${LIBRARY_SEARCH_PATH})
FIND_LIBRARY(LIBIMGPROC NAMES libopencv_imgproc.so PATHS ${LIBRARY_SEARCH_PATH})
FIND_LIBRARY(LIB_BOOST_TEST
NAMES libboost_unit_test_framework.so
PATHS ${LIBRARY_SEARCH_PATH})
INCLUDE_DIRECTORIES(include/
jni_fexample/
fexample/
${CV_H}
${HIGHGUI_H}
${EXPAT_H}
${JNI_H}
${JNI_M_H}
)
# Here is out library
ADD_LIBRARY(cvconvnet SHARED ${CVCONVNET_SRCS})
ADD_LIBRARY(cvconvnet_static STATIC ${CVCONVNET_SRCS})
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
# Here are our test programs
ADD_EXECUTABLE(testimg ${EXAMPLEIMG_SRCS})
ADD_EXECUTABLE(testmnist ${EXAMPLEMNIST_SRCS})
ADD_EXECUTABLE(ftestimg ${FEXAMPLEIMG_SRCS})
ADD_EXECUTABLE(facedetect ${FACEDETECT_SRCS})
ADD_EXECUTABLE(test_cvmaxoperatorplane ${TEST_SRCS})
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# Compiler options are different for Release and Debug
IF (CMAKE_BUILD_TYPE MATCHES Release)
# Highly optimized + cancel all assert()s
ADD_DEFINITIONS(-O3 -DNDEBUG)
ELSE ()
# Include debug info, profiling info, some text output
ADD_DEFINITIONS(-O -pg -g -DDEBUG)
# Set profiling for linker too
SET_TARGET_PROPERTIES(testmnist PROPERTIES LINK_FLAGS "-pg")
ENDIF ()
# fpic
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC" )
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fPIC" )
# We should link our test programs to libraries
TARGET_LINK_LIBRARIES(
facedetect
cvconvnet
${LIBCV}
${LIBHIGHGUI}
${LIBEXPAT}
${LIBOBJDETECT}
${LIBIMGPROC}
)
TARGET_LINK_LIBRARIES(
testimg
cvconvnet
${LIBCV}
${LIBHIGHGUI}
${LIBEXPAT}
${LIBIMGPROC}
)
TARGET_LINK_LIBRARIES(
testmnist
cvconvnet
${LIBCV}
${LIBHIGHGUI}
${LIBEXPAT}
)
TARGET_LINK_LIBRARIES(
ftestimg
cvconvnet
${LIBCV}
${LIBHIGHGUI}
${LIBEXPAT}
${LIBIMGPROC}
)
TARGET_LINK_LIBRARIES(
test_cvmaxoperatorplane
cvconvnet
${LIBCV}
${LIB_BOOST_TEST}
${LIBEXPAT}
)
FILE(GLOB files "include/*.h")
INSTALL(FILES ${files} DESTINATION /usr/local/include)
INSTALL(TARGETS cvconvnet
LIBRARY DESTINATION /usr/local/lib
)