-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathCMakeLists.txt
243 lines (195 loc) · 9.39 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
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
cmake_minimum_required(VERSION 2.8.3)
project(sp_segmenter C CXX)
SET(CMAKE_BUILD_TYPE "Release")
OPTION(BUILD_ROS_BINDING "Build ROS Binding" ON)
OPTION(BUILD_USE_OBJRECRANSAC "Use ObjRecRANSAC" ON)
OPTION(BUILD_PYTHON_BINDING "Build Python Binding" OFF)
OPTION(BUILD_ENABLE_TRACKING "Build Enable Tracking Keypoints (EXPERIMENTAL)" OFF)
OPTION(BUILD_SCENE_PARSING_SUPPORT
"Build with Scene Parsing Hypothesis Message (EXPERIMENTAL)" ON)
# Enable C++11
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support, or our tests failed to detect it correctly. Please use a different C++ compiler or report this problem to the developers.")
endif()
if (UNIX)
message(STATUS "Setting GCC flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -g -Wall")
else()
message(STATUS "Setting MSVC flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
endif()
message(STATUS "** CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# CORE LIBRARIES NEEDED FOR SP_SEGMENTER
find_package(PCL REQUIRED)
find_package(OpenCV 2 REQUIRED)
find_package(OpenMP )
find_package(Boost)
find_package(VTK)
IF(NOT VTK_FOUND)
message(FATAL_ERROR "VTK not found. VTK is not installed or cmake can not find it. Install VTK first and then try again.
If VTK is installed but cmake can not find it, set the VTK_DIR entry to the folder which contains the file VTKConfig.cmake")
ENDIF(NOT VTK_FOUND)
IF(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
add_definitions(-DUSE_OPENMP)
message (STATUS "Found OpenMP")
ENDIF(OPENMP_FOUND)
# COSTAR specific application. Leave this off all time if you are not working at costar
OPTION(TURN_THIS_OFF "TURN_THIS_OFF" ON)
if (TURN_THIS_OFF)
message(STATUS "Warning, only turn this on when you are a part of CoSTAR team. You will need to have costar_objrec_msgs from costar_stack package in github to compile this successfully")
ADD_DEFINITIONS( -DCOSTAR)
endif()
# Build ROS BINDING
IF (BUILD_ROS_BINDING)
find_package(catkin REQUIRED COMPONENTS sensor_msgs std_msgs message_generation pcl_conversions geometry_msgs tf tf_conversions costar_objrec_msgs QUIET)
ADD_DEFINITIONS( -DBUILD_ROS_BINDING)
add_service_files(
FILES SPSegmenterServer.srv SegmentInGripper.srv
)
generate_messages( DEPENDENCIES std_msgs )
if (APPLE)
catkin_package(
CATKIN_DEPENDS sensor_msgs geometry_msgs message_runtime
# DEPENDS PCL OpenCV ObjRecRANSAC
)
else()
catkin_package(
CATKIN_DEPENDS sensor_msgs geometry_msgs message_runtime
# DEPENDS PCL OpenCV OpenMP
)
endif()
if(BUILD_SCENE_PARSING_SUPPORT)
ADD_DEFINITIONS( -DSCENE_PARSING)
endif()
ENDIF()
IF (BUILD_ROS_BINDING)
include_directories(include utility ${Boost_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)
link_directories(${PCL_LIBRARY_DIRS} ${OpenCV_LIBRARY_DIRS}
${catkin_LIBRARY_DIRS}
)
ELSE()
include_directories(include utility)
include_directories(${Boost_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
ENDIF()
add_definitions(${PCL_DEFINITIONS} ${OpenCV_DEFINITIONS})
add_library(Utility
include/sp_segmenter/utility/typedef.h include/sp_segmenter/utility/utility.h utility/utility.cpp
include/sp_segmenter/utility/mcqd.h utility/mcqd.cpp include/sp_segmenter/seg.h src/seg.cpp)
add_library(linear utility/liblinear/linear.h utility/liblinear/tron.h
utility/liblinear/linear.cpp utility/liblinear/predict.c utility/liblinear/tron.cpp
utility/liblinear/blas/blas.h utility/liblinear/blas/blasp.h utility/liblinear/blas/daxpy.c
utility/liblinear/blas/ddot.c utility/liblinear/blas/dnrm2.c utility/liblinear/blas/dscal.c)
add_library(PoolLib include/sp_segmenter/features.h src/features.cpp src/HierFea.cpp src/Int_Imager.cpp src/Pooler_L0.cpp src/sp.cpp)
add_library(DataParser include/sp_segmenter/UWDataParser.h include/sp_segmenter/BBDataParser.h include/sp_segmenter/JHUDataParser.h src/UWDataParser.cpp src/BBDataParser.cpp src/JHUDataParser.cpp)
target_link_libraries(Utility linear ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${VTK_LIBS} )
target_link_libraries(PoolLib Utility linear ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${VTK_LIBS} )
target_link_libraries(DataParser Utility ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${VTK_LIBS} )
add_library(SpCompact src/sp_compact.cpp)
target_link_libraries(SpCompact PoolLib Utility linear ${Boost_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${VTK_LIBS} )
add_library(SemanticSegmentation src/semantic_segmentation.cpp src/table_segmenter.cpp src/spatial_pose.cpp src/common.cpp)
# Enable OBJRECRANSAC
IF (BUILD_USE_OBJRECRANSAC)
find_library(ObjRecRANSAC_LIBRARY ObjRecRANSAC)
message(STATUS "ObjRecRANSAC enabled")
ADD_DEFINITIONS( -DUSE_OBJRECRANSAC)
add_library(GreedyObjRecRANSAC include/sp_segmenter/greedyObjRansac.h src/greedyObjRansac.cpp)
include_directories(${ObjRecRANSAC_INCLUDE_DIRS})
target_link_libraries(GreedyObjRecRANSAC Utility ${ObjRecRANSAC_LIBRARY})
if(NOT EXISTS OBJREC_USE_CUDA)
FIND_PACKAGE(CUDA)
if(CUDA_FOUND)
set(OBJREC_USE_CUDA TRUE)
endif()
endif()
IF(OBJREC_USE_CUDA)
set(OBJREC_CUDA_DEVICE_ID 1 CACHE STRING "Which GPU device to use when running")
message(STATUS "CUDA Found and enabled with OBJREC_USE_CUDA=TRUE, Using CUDA GPU Device # " ${OBJREC_CUDA_DEVICE_ID})
add_definitions(-DUSE_CUDA)
add_definitions(-DCUDA_DEVICE_ID=${OBJREC_CUDA_DEVICE_ID})
set(CUDA_TOOLKIT_ROOT_DIR $ENV{CUDA_TOOLKIT_ROOT_DIR})
FIND_PACKAGE(CUDA REQUIRED)
add_definitions(-DOBJ_REC_RANSAC_PROFILE)
#add_definitions(-DOBJ_REC_RANSAC_VERBOSE)
#add_definitions(-DOBJ_REC_RANSAC_VERBOSE_1)
#add_definitions(-DOBJ_REC_RANSAC_VERBOSE_2)
ENDIF()
target_link_libraries(SemanticSegmentation Utility DataParser PoolLib GreedyObjRecRANSAC
${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${VTK_LIBS} ${Boost_LIBRARIES})
ELSE()
message(STATUS "ObjRecRANSAC disabled")
target_link_libraries(SemanticSegmentation Utility DataParser PoolLib
${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${VTK_LIBS} ${Boost_LIBRARIES})
ENDIF()
# Sample code for training and doing segmentation
add_executable(sp_compact src/main_sp_compact.cpp)
add_executable(sample_semantic_segmenter src/main_sample_semantic_segmentation.cpp)
target_link_libraries(sample_semantic_segmenter SemanticSegmentation)
IF (BUILD_ROS_BINDING)
message(STATUS "ROS Binding enabled")
add_library(RosSemanticSegmentation
include/sp_segmenter/ros_semantic_segmentation.h
src/ros_semantic_segmentation.cpp)
IF (BUILD_ENABLE_TRACKING)
ADD_DEFINITIONS( -DUSE_TRACKING)
add_library(Tracking src/tracker.cpp src/klttracker.cpp src/PnPUtil.cpp)
target_link_libraries(Tracking ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES} ${catkin_LIBRARIES})
target_link_libraries(RosSemanticSegmentation ${catkin_LIBRARIES} Tracking SemanticSegmentation Utility DataParser PoolLib
${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${VTK_LIBS})
ELSE()
target_link_libraries(RosSemanticSegmentation ${catkin_LIBRARIES} SemanticSegmentation Utility DataParser PoolLib
${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${VTK_LIBS})
ENDIF()
add_executable(SPSegmenterServer src/sp_segmenter_server.cpp)
target_link_libraries(SPSegmenterServer RosSemanticSegmentation)
target_link_libraries(sp_compact SpCompact ${catkin_LIBRARIES})
ELSE()
message(STATUS "ROS Binding disabled")
target_link_libraries(sp_compact SpCompact)
ENDIF()
IF (BUILD_PYTHON_BINDING)
message(STATUS " Python Binding enabled. Library 'SpCompactPy' will be built which can imported to python")
message(STATUS " See python_binding/sample_training.py for an example of how to use it.")
find_package(PythonInterp)
find_package(PythonLibs)
if(APPLE AND ${PYTHON_VERSION_MAJOR} EQUAL 3)
find_package(Boost COMPONENTS python3)
else()
find_package(Boost COMPONENTS python)
endif()
INCLUDE_DIRECTORIES(python_binding ${PYTHON_INCLUDE_DIRS})
LINK_LIBRARIES(${PYTHON_LIBRARIES})
add_library(SpCompactPy SHARED python_binding/py_sp_compact.cpp)
add_library(SemanticSegmentationPy SHARED python_binding/py_semantic_segmentation.cpp)
set_target_properties( SpCompactPy SemanticSegmentationPy
PROPERTIES
PREFIX ""
)
IF (BUILD_ROS_BINDING)
# Put the library into catkin's pythonpath
set_target_properties ( SpCompactPy SemanticSegmentationPy
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}
)
ENDIF()
IF (APPLE)
set_target_properties( SpCompactPy SemanticSegmentationPy
PROPERTIES SUFFIX ".so" )
ENDIF()
target_link_libraries(SpCompactPy SpCompact ${Boost_LIBRARIES})
target_link_libraries(SemanticSegmentationPy SemanticSegmentation ${Boost_LIBRARIES})
ELSE()
message(STATUS "Python Binding disabled.")
ENDIF()
# add_executable(TestSymmetricOrientationRealignment src/TestSymmetricOrientationRealignment.cpp)
# target_link_libraries(TestSymmetricOrientationRealignment semanticSegmentation Utility DataParser PoolLib ${Boost_LIBRARIES} )