forked from kipr/libwallaby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
182 lines (135 loc) · 5.44 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
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)
option(no_wallaby "Not a wallaby controller" OFF)
if(no_wallaby)
add_definitions(-DNOT_A_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()
if(DEFINED ENV{ZBAR_DIR})
set(ZBAR_DIR $ENV{ZBAR_DIR})
elseif(WIN32)
set(ZBAR_DIR "C:/Program Files (x86)/ZBar")
endif()
#find_package(OpenCV REQUIRED )
find_package(JPEG REQUIRED)
find_package (Threads)
include_directories(${CMAKE_INSTALL_PREFIX}/include)
include_directories(${OPENCV_INCLUDE})
include_directories(${JPEG_INCLUDE_DIR})
include_directories(${ZBAR_DIR}/include)
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
link_directories(${OPENCV_LIB})
link_directories(${ZBAR_DIR}/lib)
option(build_python "Build python bindings" ON)
file(GLOB SWIG_SOURCES ${BINDINGS}/*.i)
if(build_python)
find_package(SWIG REQUIRED)
find_package(PythonLibs 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}/wallaby -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)
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)
endif()
# Library: libwallaby
add_library(wallaby 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)
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} wallaby)
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 wallaby DESTINATION lib)
install(DIRECTORY ${INCLUDE}/wallaby DESTINATION include)
set(CMAKE_INSTALL_PREFIX /usr)