-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
206 lines (170 loc) · 6.57 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
cmake_minimum_required(VERSION 2.8)
project(obzerver)
find_package(PkgConfig)
set(PROJECT_VERSION_MAJOR "0")
set(PROJECT_VERSION_MINOR "1")
set(PROJECT_VERSION_PATCH "0")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(WITH_TESTS 0 CACHE BOOL "Build Tests (Requires Google Testing Framework)")
#set(USE_CUSTOM_OPENCV 0 CACHE BOOL "Use Custom Path for OpenCV (Provided by OpenCV_DIR")
# This requires downloading and compiling two external deps
set(WITH_PF_CCV_TRACKER 0 CACHE BOOL "Build Particle Filter and Object Detection Based Single Object Tracker")
set(EXTERNAL_DEVEL_SPACE "${CMAKE_CURRENT_BINARY_DIR}" CACHE STR "")
set(obzerver_SOURCES
src/utility.cpp
src/benchmarker.cpp
src/camera_tracker.cpp
src/self_similarity.cpp
src/fft.cpp
src/tobject.cpp
src/logger.cpp
src/roi_extraction.cpp
src/hungarian.cpp
src/kalman.cpp
src/multi_object_tracker.cpp
src/periodicity_app.cpp
)
set(obzerver_HEADERS
include/obzerver/common_types.hpp
include/obzerver/utility.hpp
include/obzerver/benchmarker.hpp
include/obzerver/circular_buffer.hpp
include/obzerver/camera_tracker.hpp
include/obzerver/self_similarity.hpp
include/obzerver/fft.hpp
include/obzerver/tobject.hpp
include/obzerver/logger.hpp
include/obzerver/opencv3-backport/shift.hpp
include/obzerver/roi_extraction.hpp
include/obzerver/hungarian.hpp
include/obzerver/kalman.hpp
include/obzerver/multi_object_tracker.hpp
include/obzerver/periodicity_app.hpp
)
#if(USE_CUSTOM_OPENCV)
# message(STATUS "Using custom OpenCV path: ${OpenCV_DIR}")
# find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR} NO_DEFAULT_PATH)
#else(USE_CUSTOM_OPENCV)
# message(STATUS "Using default OpenCV path.")
# find_package(OpenCV REQUIRED)
#endif(USE_CUSTOM_OPENCV)
include_directories(${obzerver_SOURCE_DIR}/include)
find_package(OpenCV 2.4 REQUIRED)
if(OpenCV_FOUND)
include_directories(${OpenCV_INCLUDE_DIRS})
set(LIBS ${LIBS} ${OpenCV_LIBS})
message(STATUS "OpenCV include dir: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "OpenCV CXXFLAGS: ${OpenCV_CXXFLAGS_OTHER}")
message(STATUS ${OpenCV_LIBS})
endif(OpenCV_FOUND)
## glog debian package is available only on Ubuntu Trusy+
pkg_check_modules(GLOG REQUIRED libglog)
include_directories(${GLOG_INCLUDE_DIRS})
set(LIBS ${LIBS} ${GLOG_LIBRARIES})
## Boost (for program options)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.45.0 REQUIRED COMPONENTS program_options)
include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
# -march=corei7-avx -mtune=corei7-avx -mno-avx -mno-aes
# -fopenmp is because of upstram dbscan, fix it
set(CMAKE_OPT_FLAGS "-march=native -ffast-math -funroll-loops")
set(CMAKE_CXX_FLAGS "${CMAKE_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${OpenCV_CXXFLAGS_OTHER} ${GLOG_CXXFLAGS_OTHER} -std=c++11 -Wall -Wextra -fopenmp -march=native")
## Build and Configure External Dependencies (Modified)
include(ExternalProject)
include_directories(${EXTERNAL_DEVEL_SPACE}/include)
message(STATUS "Devel install directory for external deps: ${CMAKE_CURRENT_BINARY_DIR}")
if(WITH_PF_CCV_TRACKER)
message(STATUS "Building Particle Filter based Single Object Tracker (w/ ccv and smctc)")
set(obzerver_SOURCES ${obzerver_SOURCES}
src/object_tracker.cpp
src/ccv_wrapper.cpp
)
set(obzerver_HEADERS ${obzerver_HEADERS}
include/obzerver/object_tracker.hpp
include/obzerver/ccv_wrapper.hpp
)
add_executable(ccv_demo src/ccv_demo.cpp)
target_link_libraries(ccv_demo obzerver ${OpenCV_LIBS} ${GLOG_LIBRARIES})
# libsmctc
ExternalProject_Add(libsmctc
GIT_REPOSITORY https://github.com/mani-monaj/smctc.git
GIT_TAG master
PREFIX ${CMAKE_CURRENT_BINARY_DIR}
CMAKE_ARGS
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
INSTALL_COMMAND make install
BUILD_IN_SOURCE 0
)
set(LIBS ${LIBS} "${CMAKE_CURRENT_BINARY_DIR}/lib/libsmctc.so")
# libccv's build system is convoluted
ExternalProject_Add(libccv_project
URL https://github.com/mani-monaj/ccv-lean/archive/stable.zip
PREFIX ${CMAKE_CURRENT_BINARY_DIR}
CONFIGURE_COMMAND cd lib && ./configure --with-cuda=no --prefix=${CMAKE_CURRENT_BINARY_DIR}
BUILD_COMMAND cd lib && make
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/libccv_project/lib)
# We also need to take care of libccv's transitive dependencies (png, jpeg and dispatch, more might be needed)
set(LIBS ${LIBS} "${CMAKE_CURRENT_BINARY_DIR}/src/libccv_project/lib/libccv.a;dispatch;jpeg;png;BlocksRuntime;gsl;gslcblas")
endif(WITH_PF_CCV_TRACKER)
# dbscan
ExternalProject_Add(libdbscan_project
#GIT_REPOSITORY https://github.com/mani-monaj/DBSCAN.git
#GIT_TAG master
URL ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/DBSCAN-38d47b8.zip
CMAKE_ARGS
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_DEVEL_SPACE}
-DBUILD_PYTHONLIB=OFF
-DWITH_OPENMP=ON
INSTALL_COMMAND make install
BUILD_IN_SOURCE 0
)
set(LIBS ${LIBS} "${EXTERNAL_DEVEL_SPACE}/lib/libdbscan.so")
## Debug
message(STATUS "Libs: ${LIBS}")
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
# Since libccv is a static library, wee need to compile obzerver as static as well
add_library(obzerver SHARED ${obzerver_SOURCES} ${obzerver_HEADERS})
target_link_libraries(obzerver ${LIBS})
add_dependencies(obzerver libsmctc libccv_project libdbscan_project)
add_executable(demo src/demo.cpp)
target_link_libraries(demo obzerver ${OpenCV_LIBS} ${GLOG_LIBRARIES})
if(WITH_TESTS)
add_subdirectory(test)
enable_testing()
add_test(NAME Test COMMAND obz_tests)
endif(WITH_TESTS)
# Without proper find-obzerver.cmake, the library wont work with isolated
# catkin workspaces.
# The cmake.in file has been borrowed from mavlink project
set(PKG_NAME ${PROJECT_NAME})
set(PKG_VERSION ${PROJECT_VERSION})
set(PKG_DESC "obzerver")
set(PKG_LIBRARIES )
set(PKG_DEPENDS )
configure_file(config.cmake.in ${PROJECT_NAME}-config.cmake @ONLY)
install(
FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
DESTINATION share/${PROJECT_NAME}/cmake/ COMPONENT cmake
)
install(TARGETS obzerver
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(FILES ${obzerver_HEADERS}
DESTINATION include/obzerver
)
install(
FILES package.xml
DESTINATION share/${PROJECT_NAME}
)