forked from kipr/libwallaby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
237 lines (175 loc) · 7.49 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
cmake_minimum_required(VERSION 2.8)
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(no_zoobee_wallaby "Not a zoobee wallaby controller" OFF)
if(no_wallaby)
add_definitions(-DNOT_A_WALLABY)
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(BINDINGS ${CMAKE_SOURCE_DIR}/bindings)
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
include_directories(${INCLUDE})
file(GLOB SOURCES ${SRC}/*.cpp)
file(GLOB C_TESTS tests/*.c)
file(GLOB PIXELTOASTER_SOURCES ${PIXELTOASTER}/*.cpp)
# Cross-compile
# set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
# set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
# C++11
# http://www.guyrutenberg.com/2014/01/05/enabling-c11-c0x-in-cmake/
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)
add_definitions(--std=c++11)
elseif(COMPILER_SUPPORTS_CXX0X)
add_definitions(--std=c++0x)
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# 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()
find_package(OpenCV REQUIRED )
find_package(JPEG REQUIRED)
find_package (Threads)
find_package( PythonInterp 2.7 REQUIRED )
find_package( PythonLibs 2.7 REQUIRED )
include_directories(${CMAKE_INSTALL_PREFIX}/include)
include_directories(${OPENCV_INCLUDE})
include_directories(${JPEG_INCLUDE_DIR})
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
link_directories(${OPENCV_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(PythonLibs 2.7 REQUIRED)
message("${PYTHON_LIBRARY}")
set(PYTHON_BINDING_SOURCES ${CMAKE_BINARY_DIR}/kipr_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}/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})
add_library(kipr SHARED ${SOURCES} ${PIXELTOASTER_SOURCES} ${OBJC_SOURCES})
target_link_libraries(wallaby ${OpenCV_LIBS} ${JPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} zbar opencv_core opencv_highgui opencv_imgproc)
target_link_libraries(kipr ${OpenCV_LIBS} ${JPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} zbar opencv_core opencv_highgui opencv_imgproc)
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
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()
########################################
# 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()
install(TARGETS ${TESTS} DESTINATION bin/wallaby)
install(TARGETS ${TESTS} DESTINATION bin/kipr)
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)
# 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
)