-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists_common.txt
268 lines (223 loc) · 9.02 KB
/
CMakeLists_common.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0011 NEW)
cmake_policy(SET CMP0012 NEW)
endif(COMMAND cmake_policy)
INCLUDE_REGULAR_EXPRESSION("^.*$")
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USE_REVERSE_INDEXING /O2")
#SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:msvcprt.lib ")
elseif(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -msse2 -ftemplate-depth-50 -D USE_REVERSE_INDEXING ")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -Wno-deprecated -msse2 -ftemplate-depth-50")
elseif(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USE_REVERSE_INDEXING ")
set(CMAKE_C_COMPILER "g++")
set(CMAKE_CXX_COMPILER "g++")
endif()
# Release mode
SET(CMAKE_BUILD_TYPE Release)
#SET(CMAKE_BUILD_TYPE Debug)
# Advanced options
option(USE_ITK "use ITK library" on)
mark_as_advanced(USE_ITK)
option(USE_LIBDAI "use libdai library" on)
mark_as_advanced(USE_LIBDAI)
option(USE_MRF "use MRF library" off)
mark_as_advanced(USE_MRF)
option(USE_MAXFLOW "use maxflow library" on)
mark_as_advanced(USE_MAXFLOW)
option(USE_MULTIOBJ "use multiobj library" on)
mark_as_advanced(USE_MULTIOBJ)
option(USE_SIFT "use SIFT library" off)
mark_as_advanced(USE_SIFT)
if(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /D_WINDOWS /w /Zi /EHsc /GR /MP /openmp ")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_AMD64_ ")
elseif(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(CMAKE_CXX_FLAGS_DEBUG "-g -pg")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
elseif(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(CMAKE_CXX_FLAGS_DEBUG "-g -pg")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
else()
message(WARNING "unrecognized architecture")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D WITH_PNG -D WITH_OPENMP")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -std=gnu++0x")
###################################################################### THIRD_PARTY_LIBS
set(OpenCV_DIR "~/src/opencv-3.0.0-alpha/build" CACHE PATH "opencv dir path" )
set(ITK_DIR "~/src/InsightToolkit-4.7.1/build" CACHE PATH "itk dir path" )
###################################################################### PACKAGES
include_directories(${OPENCV_INCLUDE_DIRS_EXTRA})
FIND_PACKAGE(OpenCV REQUIRED)
# add include directories
include_directories(${OpenCV_INCLUDE_DIRS})
#message(STATUS "OpenCV DIR: ${OpenCV_DIR}")
#message(STATUS "OpenCV include dir: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "OpenCV libs: ${OpenCV_LIBS}")
# OpenCV sometimes places libraries in weird places
set(OpenCV_ADDITIONAL_LIB_DIRS "${OpenCV_DIR}/lib/" CACHE STRING "additional dirs where cmake should look for opencv libs")
link_directories(${OpenCV_ADDITIONAL_LIB_DIRS})
#Superpixel library
find_library(SUPERPIXEL_LIBRARY NAMES supervoxel PATHS ${SLICEME_DIR}/lib/slic/
${SLICEME_DIR}/lib/slic/build
${SLICEME_DIR}/lib/slic/build/Release)
# ITK
if(USE_ITK)
find_package(ITK REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USE_ITK")
endif(USE_ITK)
###################################################################### INCLUDES
# include directories
include_directories(${SLICEME_DIR}/core/)
# superpixel/supervoxel library
include_directories(${SLICEME_DIR}/lib/slic/)
# libsvm
#include_directories(${SLICEME_DIR}/lib/libsvm-3.0)
# ITK
if(USE_ITK)
IF(ITK_FOUND)
INCLUDE(${ITK_USE_FILE})
# include itk aux
# lib/itkStructureTensorRecursiveGaussianImageFilter.h
# lib/itkStructureTensorRecursiveGaussianImageFilter.txx
include_directories(${SLICEME_DIR}/lib/)
ENDIF(ITK_FOUND)
endif(USE_ITK)
# libDAI
if(USE_LIBDAI)
include_directories(${SLICEME_DIR}/lib/libDAI024/include/)
find_library(LIBDAI_LIBRARY NAMES dai PATHS "${SLICEME_DIR}/lib/libDAI024/"
"${SLICEME_DIR}/lib/libDAI024/build/"
"${SLICEME_DIR}/lib/libDAI024/build/Release/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USE_LIBDAI")
#libDAI requires boost/foreach.hpp ?
find_package(Boost 1.37.0 COMPONENTS program_options REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
endif(USE_LIBDAI)
# MRF
if(USE_MRF)
include_directories(${SLICEME_DIR}/lib/MRF2.1/)
find_library(MRF_LIBRARY NAMES MRF PATHS ${SLICEME_DIR}/lib/MRF2.1/)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USE_MRF")
endif(USE_MRF)
# maxflow
if(USE_MAXFLOW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USE_MAXFLOW")
include_directories(${SLICEME_DIR}/lib/graphCuts/)
endif(USE_MAXFLOW)
#multiobj
if(USE_MULTIOBJ)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USE_MULTIOBJ")
endif(USE_MULTIOBJ)
# sift
if(USE_SIFT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USE_SIFT")
find_library(SIFT_LIBRARY NAMES sift PATHS ${SLICEME_DIR}/lib/siftpp/g64)
include_directories(${SLICEME_DIR}/lib/siftpp)
endif(USE_SIFT)
find_package(ZLIB REQUIRED)
#if(NOT ZLIB_FOUND)
#set(ZLIB_INCLUDE_DIRS ${SLICEME_DIR}/lib/zlib-1.2.3-lib/include CACHE STRING "zlib include dir")
#set(ZLIB_LIBRARIES ${SLICEME_DIR}/lib/zlib-1.2.3-lib/lib/zlib.lib CACHE STRING "zlib lib")
#else()
#set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR} CACHE STRING "zlib include dir")
#set(ZLIB_LIBRARIES ${ZLIB_LIBRARY} CACHE STRING "zlib lib")
#endif()
include_directories(${ZLIB_INCLUDE_DIR})
#include_directories(${ZLIB_INCLUDE_DIRS})
message(STATUS "zlib include dir: ${ZLIB_INCLUDE_DIRS}")
####################################################################### OPTIONS
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -pg")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3")
set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
######################################################################### FILES
set(SLICEME_FILES
${SLICEME_DIR}/core/colormap.cpp
${SLICEME_DIR}/core/Config.cpp
${SLICEME_DIR}/core/Feature.cpp
${SLICEME_DIR}/core/F_Bias.cpp
${SLICEME_DIR}/core/F_ColorHistogram.cpp
${SLICEME_DIR}/core/F_Combo.cpp
${SLICEME_DIR}/core/F_Dft.cpp
${SLICEME_DIR}/core/F_Gaussian.cpp
${SLICEME_DIR}/core/F_Glcm.cpp
${SLICEME_DIR}/core/F_Histogram.cpp
${SLICEME_DIR}/core/F_LoadFromFile.cpp
${SLICEME_DIR}/core/F_OrientedHistogram.cpp
${SLICEME_DIR}/core/F_Position.cpp
${SLICEME_DIR}/core/F_Precomputed.cpp
${SLICEME_DIR}/core/Histogram.cpp
${SLICEME_DIR}/core/oSVM.cpp
${SLICEME_DIR}/core/Slice3d.cpp
${SLICEME_DIR}/core/Slice.cpp
${SLICEME_DIR}/core/Slice_P.cpp
${SLICEME_DIR}/core/Supernode.cpp
${SLICEME_DIR}/core/StatModel.cpp
${SLICEME_DIR}/core/utils.cpp
${SLICEME_DIR}/core/svm_struct/svm_struct_common.c
${SLICEME_DIR}/core/svm_struct/svm_struct_learn.c
${SLICEME_DIR}/core/svm_light/svm_common.c
${SLICEME_DIR}/core/svm_light/svm_hideo.c
${SLICEME_DIR}/core/svm_light/svm_learn.c
${SLICEME_DIR}/core/svm_struct_api.c
${SLICEME_DIR}/core/svm_struct_learn_custom.c
${SLICEME_DIR}/core/constraint_set.cpp
${SLICEME_DIR}/core/label_cache.cpp
${SLICEME_DIR}/core/inference_globals.cpp
${SLICEME_DIR}/core/energyParam.cpp
${SLICEME_DIR}/core/inference.cpp
${SLICEME_DIR}/core/graphInference.cpp
${SLICEME_DIR}/core/gi_ICM.cpp
${SLICEME_DIR}/core/gi_max.cpp
${SLICEME_DIR}/core/gi_MF.cpp
${SLICEME_DIR}/core/gi_sampling.cpp
)
if(WIN32)
set(SLICEME_FILES ${SLICEME_FILES}
${SLICEME_DIR}/core/gettimeofday.c
${SLICEME_DIR}/core/getopt.c
${SLICEME_DIR}/core/getopt_long.c
)
endif()
SET_SOURCE_FILES_PROPERTIES( ${SLICEME_FILES} PROPERTIES LANGUAGE CXX )
SET_SOURCE_FILES_PROPERTIES( ${SLICEME_DIR}/core/getopt_long.c ${SLICEME_DIR}/core/getopt.h ${SLICEME_DIR}/core/getopt.c PROPERTIES LANGUAGE C )
if(USE_LIBDAI)
set(SLICEME_FILES ${SLICEME_FILES} ${SLICEME_DIR}/core/gi_libDAI.cpp)
set(INFERENCE_THIRD_PARTY_LIBRARIES ${INFERENCE_THIRD_PARTY_LIBRARIES} ${LIBDAI_LIBRARY})
endif(USE_LIBDAI)
if(USE_MRF)
set(SLICEME_FILES ${SLICEME_FILES} ${SLICEME_DIR}/core/gi_MRF.cpp)
set(INFERENCE_THIRD_PARTY_LIBRARIES ${INFERENCE_THIRD_PARTY_LIBRARIES} ${MRF_LIBRARY})
endif(USE_MRF)
if(USE_MAXFLOW)
set(SLICEME_FILES ${SLICEME_FILES} ${SLICEME_DIR}/core/gi_maxflow.cpp)
endif(USE_MAXFLOW)
if(USE_MULTIOBJ)
set(SLICEME_FILES ${SLICEME_FILES} ${SLICEME_DIR}/core/gi_multiobject.cpp)
endif(USE_MULTIOBJ)
if(USE_ITK)
set(SLICEME_FILES ${SLICEME_FILES}
${SLICEME_DIR}/core/F_Filter.cpp
${SLICEME_DIR}/core/F_GradientStats.cpp)
endif(USE_ITK)
if(USE_SIFT)
set(SLICEME_FILES ${SLICEME_FILES}
${SLICEME_DIR}/core/F_Sift.cpp
${SLICEME_DIR}/lib/siftpp/sift.cpp)
endif(USE_SIFT)
set(INFERENCE_THIRD_PARTY_LIBRARIES ${INFERENCE_THIRD_PARTY_LIBRARIES} ${ZLIB_LIBRARIES} ${ZLIB_LIBRARY})
##################################################################### LIBRARIES
set(SLICEME_THIRD_PARTY_LIBRARIES ${OpenCV_LIBS} ${SUPERPIXEL_LIBRARY} ${INFERENCE_THIRD_PARTY_LIBRARIES})
if(USE_ITK)
if( ${ITK_VERSION_MAJOR} VERSION_LESS "4.0")
set(SLICEME_THIRD_PARTY_LIBRARIES ${SLICEME_THIRD_PARTY_LIBRARIES} ITKIO ITKStatistics)
else()
set(SLICEME_THIRD_PARTY_LIBRARIES ${SLICEME_THIRD_PARTY_LIBRARIES} ${ITK_LIBRARIES})
endif()
endif()