-
Notifications
You must be signed in to change notification settings - Fork 88
/
CMakeLists.txt
executable file
·337 lines (272 loc) · 8.35 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.0)
project(mynteyed VERSION 1.9.0 LANGUAGES C CXX)
include(cmake/Common.cmake)
if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX d)
endif()
# options
option(DEBUG "Enable Debug Log" OFF)
option(TIMECOST "Enable Time Cost" OFF)
add_definitions(-DLOG_TAG=MYNTEYE)
if(DEBUG)
add_definitions(-DDEBUG)
message(STATUS "Using macro DEBUG")
endif()
if(TIMECOST)
add_definitions(-DTIME_COST)
message(STATUS "Using macro TIME_COST")
endif()
# config
set(MYNTEYE_NAME "${PROJECT_NAME}")
set(MYNTEYE_ROOT "${PROJECT_SOURCE_DIR}")
if(NOT MYNTEYE_NAMESPACE)
set(MYNTEYE_NAMESPACE "${MYNTEYE_NAME}")
endif()
configure_file(
include/mynteyed/stubs/global_config.h.in
include/mynteyed/stubs/global_config.h @ONLY
)
# flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3")
include(cmake/DetectCXX11.cmake)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
string(STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
string(STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
message(STATUS "C_FLAGS: ${CMAKE_C_FLAGS}")
message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# packages
LIST(APPEND CMAKE_MODULE_PATH ${MYNTEYE_ROOT}/cmake)
set(OpenCV_FIND_QUIET TRUE)
include(${MYNTEYE_ROOT}/cmake/DetectOpenCV.cmake)
set(JPEG_FIND_QUIET TRUE)
include(${MYNTEYE_ROOT}/cmake/DetectJPEG.cmake)
find_package(eSPDI REQUIRED)
# rpath
set(CMAKE_MACOSX_RPATH 1)
set(MYNTEYE_CMAKE_RPATH "${CMAKE_INSTALL_PREFIX}/lib/3rdparty")
if(WITH_OPENCV)
message(STATUS "OpenCV_LIB_PATH: ${OpenCV_LIB_PATH}")
list(APPEND MYNTEYE_CMAKE_RPATH ${OpenCV_LIB_PATH})
endif()
set(CMAKE_INSTALL_RPATH "${MYNTEYE_CMAKE_RPATH}")
# targets
set(OUTPUT_DIR "${MYNTEYE_ROOT}/_output")
set_outdir(
ARCHIVE ${OUTPUT_DIR}/lib
LIBRARY ${OUTPUT_DIR}/lib
RUNTIME ${OUTPUT_DIR}/bin
)
if(WITH_OPENCV)
include_directories(
${OpenCV_INCLUDE_DIRS}
)
endif()
if(WITH_JPEG)
include_directories(
${JPEG_INCLUDE_DIR}
)
endif()
include_directories(
${eSPDI_INCLUDE_DIRS}
${MYNTEYE_ROOT}/include
${CMAKE_CURRENT_BINARY_DIR}/include
)
add_definitions(-DMYNTEYE_EXPORTS)
## mynteye_depth
set(MYNTEYE_DEPTH mynteye_depth)
set(MYNTEYE_DEPTH_SRCS
src/mynteyed/data/channels.cc
src/mynteyed/device/colorizer_p.cc
src/mynteyed/device/convertor.cc
src/mynteyed/device/data_caches.cc
src/mynteyed/device/device_info.cc
src/mynteyed/device/device.cc
src/mynteyed/device/image.cc
src/mynteyed/device/open_params.cc
src/mynteyed/device/stream_info.cc
src/mynteyed/device/types.cc
src/mynteyed/stubs/types_calib.cc
src/mynteyed/util/rate.cc
src/mynteyed/util/strings.cc
src/mynteyed/camera.cc
src/mynteyed/types_data.cc
src/mynteyed/utils.cc
src/mynteyed/internal/camera_p.cc
src/mynteyed/internal/image_utils.cc
src/mynteyed/internal/streams.cc
src/mynteyed/internal/match.cc
src/mynteyed/internal/motions.cc
src/mynteyed/internal/location.cc
src/mynteyed/internal/distance.cc
src/mynteyed/filter/base_filter.cpp
src/mynteyed/filter/filter_spigot.cpp
src/mynteyed/filter/spatial_filter.cpp
src/mynteyed/filter/temporal_filter.cpp
)
if(OS_WIN)
list(APPEND MYNTEYE_DEPTH_SRCS
src/mynteyed/data/hid/hid_win.cc
src/mynteyed/device/win/device_win.cc
src/mynteyed/device/win/color_palette_generator.cc
src/mynteyed/device/win/colorizer_win.cc
)
else()
list(APPEND MYNTEYE_DEPTH_SRCS
src/mynteyed/data/hid/hid_linux.cc
src/mynteyed/device/linux/device_linux.cc
src/mynteyed/device/linux/color_palette_generator.cc
src/mynteyed/device/linux/colorizer_linux.cc
)
endif()
if(OS_WIN)
set(MYNTEYE_LINK_LIBS ${eSPDI_LIBS})
else()
set(MYNTEYE_LINK_LIBS ${eSPDI_LIBS} "usb" -lpthread)
endif()
if(WITH_OPENCV)
list(APPEND MYNTEYE_LINK_LIBS ${OpenCV_LIBS})
endif()
if(WITH_JPEG)
list(APPEND MYNTEYE_LINK_LIBS ${JPEG_LIBRARIES})
endif()
make_shared_library(${MYNTEYE_DEPTH}
SRCS ${MYNTEYE_DEPTH_SRCS}
LINK_LIBS ${MYNTEYE_LINK_LIBS}
)
target_include_directories(${MYNTEYE_DEPTH} PUBLIC
"$<BUILD_INTERFACE:${MYNTEYE_ROOT}/src>"
"$<INSTALL_INTERFACE:include>"
)
set_target_properties(${MYNTEYE_DEPTH} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
# copy 3rdparty libraries
if(OS_WIN)
set(__3rdparty_out_dir ${OUTPUT_DIR}/bin/3rdparty)
else()
set(__3rdparty_out_dir ${OUTPUT_DIR}/lib/3rdparty)
endif()
set(__expr ".so*")
if(OS_WIN)
set(__expr "*.dll")
elseif(OS_MAC)
set(__expr "*.dylib")
endif()
if(eSPDI_LIBRARY)
set(__espdi_libs "")
set(__espdi_symlinks "")
list(APPEND eSPDI_LIBS ${eSPDI_3PARTY_LIBS})
foreach(__espdi_lib ${eSPDI_LIBS})
string(REGEX MATCH "^${MYNTEYE_ROOT}/*" __match "${__espdi_lib}")
if(__match)
string(REGEX REPLACE "\\.[^.]*$" "${__expr}" __espdi_lib ${__espdi_lib})
file(GLOB __espdi_lib2 "${__espdi_lib}")
foreach(__espdi_lib ${__espdi_lib2})
if(IS_SYMLINK "${__espdi_lib}")
list(APPEND __espdi_symlinks ${__espdi_lib})
else()
list(APPEND __espdi_libs ${__espdi_lib})
endif()
endforeach()
endif()
endforeach()
# Copy libs before symlinks
list(APPEND __espdi_libs ${__espdi_symlinks})
message(STATUS "Copy eSPDI_LIBS to ${__3rdparty_out_dir}")
foreach(__espdi_lib ${__espdi_libs})
get_filename_component(__espdi_name ${__espdi_lib} NAME)
if(EXISTS "${__3rdparty_out_dir}/${__espdi_name}")
message(STATUS " Skip ${__espdi_lib}")
else()
message(STATUS " Copy ${__espdi_lib}")
file(COPY ${__espdi_lib} DESTINATION ${__3rdparty_out_dir})
endif()
endforeach()
endif()
# ocvinfo.sh
configure_file(
"${MYNTEYE_ROOT}/cmake/templates/ocvinfo.sh.in"
"${MYNTEYE_ROOT}/ocvinfo.sh"
)
# pkginfo.sh
configure_file(
"${MYNTEYE_ROOT}/cmake/templates/pkginfo.sh.in"
"${MYNTEYE_ROOT}/pkginfo.sh"
)
# platforms/linux/sdk.cfg
set(SDK_OpenCV_LIB_DIR ${OpenCV_LIB_PATH})
configure_file(
"${MYNTEYE_ROOT}/cmake/templates/platforms/linux/sdk.cfg.in"
"${MYNTEYE_ROOT}/platforms/linux/sdk.cfg"
)
# winpack.nsi
if(OS_WIN)
configure_file(
scripts/win/nsis/winpack.nsi.in
${CMAKE_CURRENT_SOURCE_DIR}/winpack.nsi @ONLY
)
endif()
# install
set(MYNTEYE_CMAKE_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/${MYNTEYE_NAME}")
set(MYNTEYE_CMAKE_BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
set(MYNTEYE_CMAKE_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
set(MYNTEYE_CMAKE_INSTALLDIR "${MYNTEYE_CMAKE_LIBDIR}/cmake/${MYNTEYE_NAME}")
install(DIRECTORY
"${MYNTEYE_ROOT}/include"
"${CMAKE_CURRENT_BINARY_DIR}/include"
DESTINATION ${CMAKE_INSTALL_PREFIX}
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)
#message(STATUS "__3rdparty_out_dir: ${__3rdparty_out_dir}")
if(OS_WIN)
set(__3rdparty_dst_dir ${MYNTEYE_CMAKE_BINDIR})
else()
set(__3rdparty_dst_dir ${MYNTEYE_CMAKE_LIBDIR})
endif()
install(DIRECTORY "${__3rdparty_out_dir}"
DESTINATION "${__3rdparty_dst_dir}"
FILES_MATCHING PATTERN "*.so*" PATTERN "*.dll" PATTERN "*.dylib"
)
install(TARGETS ${MYNTEYE_DEPTH}
EXPORT mynteyed-targets
ARCHIVE DESTINATION ${MYNTEYE_CMAKE_LIBDIR}
LIBRARY DESTINATION ${MYNTEYE_CMAKE_LIBDIR}
RUNTIME DESTINATION ${MYNTEYE_CMAKE_BINDIR}
)
## cmake files
include(CMakePackageConfigHelpers)
configure_package_config_file(mynteyed-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/mynteyed-config.cmake
INSTALL_DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(mynteyed-config-version.cmake
VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/mynteyed-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/mynteyed-config-version.cmake
DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
)
install(EXPORT mynteyed-targets
#NAMESPACE mynteyed::
DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
)
# summary
include(${MYNTEYE_ROOT}/cmake/Summary.cmake)