forked from kipr/libwallaby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
267 lines (202 loc) · 8.26 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
cmake_minimum_required(VERSION 3.0)
project(libwallaby)
#set(ENV{OPENCV_INCLUDE_DIR} /home/root/Documents/KISS/bin/wallaby7/libwallaby/opencv/include)
#set(OpenCV_DIR /home/root/Documents/KISS/bin/wallaby7/libwallaby/opencv/cmake)
# Use these options based on platform:
# platform no_wallaby no_zoobee_wallaby
# desktop (Ubuntu, etc.) ON ON or OFF (don't care)
# wallaby-wallaby controller OFF ON
# zoobee-wallaby controller OFF OFF
option(no_wallaby "Not a wallaby controller" OFF)
option(emscripten "Build for use with emscripten (for simulator)" OFF)
option(with_vision_support "Controls camera support" ON)
option(build_tests "build the tests" OFF)
option(build_debian "build the debian stuff" OFF)
option(no_zoobee_wallaby "Not a zoobee wallaby controller" OFF)
if(no_wallaby)
add_definitions(-DNOT_A_WALLABY)
endif()
if(emscripten)
add_definitions(-DTARGET_EMSCRIPTEN)
endif()
if(with_vision_support)
add_definitions(-DWITH_VISION_SUPPORT)
endif()
if(USE_ARUCO)
add_definitions(-DARUCO)
endif()
if(no_zoobee_wallaby)
add_definitions(-DNOT_A_ZOOBEE_WALLABY)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(INCLUDE ${libwallaby_SOURCE_DIR}/include)
set(SRC ${libwallaby_SOURCE_DIR}/src)
set(PIXELTOASTER ${SRC}/pixeltoaster)
set(WPACLI ${SRC}/wpa_ctrl)
set(BINDINGS ${CMAKE_SOURCE_DIR}/bindings)
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
include_directories(${INCLUDE})
include_directories(${libwallaby_SOURCE_DIR}/src/wpa_ctrl/common)
file(GLOB SOURCES ${SRC}/*.cpp)
file(GLOB C_TESTS tests/*.c)
file(GLOB PIXELTOASTER_SOURCES ${PIXELTOASTER}/*.cpp)
file(GLOB WPACLI_COMMON ${WPACLI}/common/*.c)
file(GLOB WPACLI_UTILS ${WPACLI}/utils/*.c)
# Cross-compile
# set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
# set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
# C++11
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -std=c++11")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
# REMOVE ME
include_directories(${SRC}/pixeltoaster)
#############################
# PixelToaster settings #
#############################
if(APPLE)
file(GLOB OBJC_SOURCES ${PIXELTOASTER}/*.mm)
elseif(WIN32)
add_definitions(-fno-check-new)
endif()
if(DEFINED ENV{OPENCV_INCLUDE_DIR})
set(OPENCV_INCLUDE $ENV{OPENCV_INCLUDE_DIR})
elseif(WIN32)
set(OPENCV_INCLUDE ${CMAKE_SOURCE_DIR}/../opencv/build/install/include)
endif()
if(DEFINED ENV{OPENCV_LIB_DIR})
set(OPENCV_LIB $ENV{OPENCV_LIB_DIR})
elseif(WIN32)
set(OPENCV_LIB ${CMAKE_SOURCE_DIR}/../opencv/build/install/x86/vc11/lib)
endif()
if(DEFINED ENV{ZBAR_DIR})
set(ZBAR_DIR $ENV{ZBAR_DIR})
elseif(WIN32)
set(ZBAR_DIR "C:/Program Files (x86)/ZBar")
endif()
if(with_vision_support)
find_package(OpenCV REQUIRED )
find_package(JPEG REQUIRED)
endif()
find_package (Threads)
if(build_python)
find_package(Python3 REQUIRED)
endif()
include_directories(${CMAKE_INSTALL_PREFIX}/include)
if(with_vision_support)
include_directories(${OPENCV_INCLUDE})
include_directories(${JPEG_INCLUDE_DIR})
include_directories(${ZBAR_DIR}/include)
link_directories(${OPENCV_LIB})
link_directories(${ZBAR_DIR}/lib)
endif()
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
option(build_python "Build python bindings" ON)
option(USE_ARUCO "Use Aruco Markers" OFF)
file(GLOB SWIG_SOURCES ${BINDINGS}/*.i)
#if(build_python)
# find_package(SWIG REQUIRED)
# find_package(PythonLibs 2.7 REQUIRED)
# message("${PYTHON_LIBRARY}")
# set(PYTHON_BINDING_SOURCES ${CMAKE_BINARY_DIR}/wallaby_wrap_py.cxx)
# set(PYTHON_BINDING_LIBRARIES ${PYTHON_LIBRARY})
# include_directories(${PYTHON_INCLUDE_DIR})
# add_custom_command(COMMAND ${SWIG_EXECUTABLE} -Wall -python -c++ -I${INCLUDE}/kipr -outdir ${LIBRARY_OUTPUT_PATH} -o ${CMAKE_BINARY_DIR}/wallaby_wrap_py.cxx ${BINDINGS}/wallaby.i
# DEPENDS ${SWIG_SOURCES}
# OUTPUT ${CMAKE_BINARY_DIR}/wallaby_wrap_py.cxx ${LIBRARY_OUTPUT_PATH}/wallaby.py)
# install(FILES ${LIBRARY_OUTPUT_PATH}/wallaby.py DESTINATION lib)
#endif()
if(build_python)
find_package(SWIG REQUIRED)
find_package(Python3 REQUIRED)
include_directories(${PYTHON_INCLUDE_DIR})
include_directories(/usr/include/python3.9/)
set(PYTHON_BINDING_SOURCES ${CMAKE_BINARY_DIR}/kipr_wrap_py.cxx)
set(PYTHON_BINDING_LIBRARIES ${PYTHON_LIBRARIES})
add_custom_command(COMMAND ${SWIG_EXECUTABLE} -Wall -python -c++ -I${INCLUDE}/kipr -outdir ${LIBRARY_OUTPUT_PATH} -o ${CMAKE_BINARY_DIR}/kipr_wrap_py.cxx ${BINDINGS}/kipr.i
DEPENDS ${SWIG_SOURCES}
OUTPUT ${CMAKE_BINARY_DIR}/kipr_wrap_py.cxx ${LIBRARY_OUTPUT_PATH}/kipr.py)
install(FILES ${LIBRARY_OUTPUT_PATH}/kipr.py DESTINATION lib)
endif()
if(build_python)
add_library(wallaby_python SHARED ${PYTHON_BINDING_SOURCES})
set_target_properties(wallaby_python PROPERTIES PREFIX _ OUTPUT_NAME wallaby SUFFIX .so)
target_link_libraries(wallaby_python wallaby ${PYTHON_BINDING_LIBRARIES} )
install(TARGETS wallaby_python DESTINATION lib)
add_library(wombat_python SHARED ${PYTHON_BINDING_SOURCES})
set_target_properties(wombat_python PROPERTIES PREFIX _ OUTPUT_NAME kipr SUFFIX .so)
target_link_libraries(wombat_python kipr ${PYTHON_BINDING_LIBRARIES} )
install(TARGETS wombat_python DESTINATION lib)
endif()
##Changed wallaby to KIPR under three instances below: 148, 151,165
# Library: libwallaby
add_library(wallaby SHARED ${SOURCES} ${PIXELTOASTER_SOURCES} ${OBJC_SOURCES} ${WPACLI_UTILS} ${WPACLI_COMMON})
add_library(kipr SHARED ${SOURCES} ${PIXELTOASTER_SOURCES} ${OBJC_SOURCES} ${WPACLI_UTILS} ${WPACLI_COMMON})
if(with_vision_support)
link_directories(/opt/vc/lib)
target_link_libraries(wallaby ${OpenCV_LIBS} ${JPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} zbar opencv_core opencv_highgui opencv_imgproc avcodec avutil m swscale)
target_link_libraries(kipr ${OpenCV_LIBS} ${JPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} zbar opencv_core opencv_highgui opencv_imgproc avcodec avutil m swscale)
endif()
if(USE_ARUCO)
target_link_libraries(wallaby opencv_aruco)
target_link_libraries(kipr opencv_aruco)
endif()
if(APPLE)
find_library(OPENGL_LIBRARY OpenGL)
find_library(COCOA_LIBRARY Cocoa)
find_library(CORESERVICE_LIBRARY CoreServices)
target_link_libraries(wallaby ${OPENGL_LIBRARY} ${COCOA_LIBRARY} ${CORESERVICE_LIBRARY})
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(wallaby rt X11)
endif()
# Executables: test programs
# TODO: use a list and foreach to make this more concise
option(build_tests "build_tests" OFF)
if (${build_tests})
set(TESTS )
foreach(C_TEST ${C_TESTS})
get_filename_component(C_TEST_NAME ${C_TEST} NAME_WE)
set(TEST_BIN_NAME ${C_TEST_NAME}_c)
add_executable(${TEST_BIN_NAME} ${C_TEST})
target_link_libraries(${TEST_BIN_NAME} kipr)
list(APPEND TESTS ${TEST_BIN_NAME})
endforeach()
endif()
########################################
# Doxygen documentation (optional) #
########################################
option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" ON)
if(BUILD_DOCUMENTATION)
FIND_PACKAGE(Doxygen)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen is needed to build the documentation. Please install it correctly")
endif()
file(MAKE_DIRECTORY doc)
set(DOXYGEN_DIR ${PROJECT_SOURCE_DIR}/doxygen)
add_custom_target (Docs++ ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_DIR}/Doxyfile++ SOURCES ${DOXYGEN_DIR}/Doxyfile++
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
add_custom_target (Docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_DIR}/Doxyfile SOURCES ${DOXYGEN_DIR}/Doxyfile
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
add_custom_target(DocMetadata ALL
COMMAND ${CMAKE_COMMAND} -E copy ${DOXYGEN_DIR}/metadata.ini ${PROJECT_SOURCE_DIR}/doc)
endif()
if (build_tests)
install(TARGETS ${TESTS} DESTINATION bin/wallaby)
install(TARGETS ${TESTS} DESTINATION bin/kipr)
endif()
install(TARGETS kipr DESTINATION lib)
install(TARGETS wallaby DESTINATION lib)
install(DIRECTORY ${INCLUDE}/wallaby DESTINATION include)
install(DIRECTORY ${INCLUDE}/kipr DESTINATION include)
set(CMAKE_INSTALL_PREFIX /usr/local/)
if(build_debian)
# Install the manpage (appropriate for .deb package)
# manpage should have -r-wr--r-- or 644 permission (owner r-w, group r--, others r--)
install(
FILES libwallaby.1
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
DESTINATION ${DESTDIR}${CMAKE_INSTALL_PREFIX}/share/man/man1
)
endif()