This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·438 lines (365 loc) · 11.6 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# Copyright (c) 2022,Horizon Robotics.
#
# 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.5)
project(hobot_cv)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
find_package(rclcpp REQUIRED)
# x3|rdkultra|x86
set(PREFIX_PATH x3)
set(SYS_ROOT ${CMAKE_SYSROOT})
if(PLATFORM_X3)
message("build platform X3")
add_definitions(-DPLATFORM_X3)
set(PREFIX_PATH x3)
elseif(PLATFORM_Rdkultra)
message("build platform Rdkultra")
add_definitions(-DPLATFORM_Rdkultra)
set(PREFIX_PATH rdkultra)
elseif(PLATFORM_X86)
message("build platform x86")
add_definitions(-DPLATFORM_X86)
set(PREFIX_PATH x86)
set(SYS_ROOT ${THIRD_PARTY})
elseif(PLATFORM_Rdkultra)
message("build platform rdkultra")
add_definitions(-DPLATFORM_Rdkultra)
set(PREFIX_PATH rdkultra)
set(SYS_ROOT ${THIRD_PARTY})
else()
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
message("invalid platform, build platform X3 default")
add_definitions(-DPLATFORM_X3)
set(PLATFORM_X3 ON)
set(PREFIX_PATH x3)
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
message("build platform X86")
add_definitions(-DPLATFORM_X86)
set(PLATFORM_X86 ON)
set(PREFIX_PATH x86)
set(SYS_ROOT ${THIRD_PARTY})
endif()
endif()
message("PREFIX_PATH is " ${PREFIX_PATH})
message("SYS_ROOT is " ${SYS_ROOT})
message("PROJECT_SOURCE_DIR" ${PROJECT_SOURCE_DIR})
include_directories(include
include/${PREFIX_PATH}
${PROJECT_SOURCE_DIR}
${SYS_ROOT}/usr/include/
${SYS_ROOT}/usr/include/opencv/
thirdparty/include/
)
link_directories(
${SYS_ROOT}/usr/lib/
${SYS_ROOT}/usr/lib/hbbpu/
${SYS_ROOT}/usr/lib/hbmedia/
thirdparty/lib/
)
SET(LINK_LIBS dnn opencv_world)
if(PLATFORM_X3)
SET(VPS_LIBS isp_algo z hbmedia isp ion multimedia iar tinyalsa cjson diag gdcbin vio dl)
SET(NEON_LIBS hobotcv_neon_blur)
add_library(${PROJECT_NAME} SHARED
src/utils.cpp
src/x3/hobotcv_imgproc/hobotcv_imgproc.cpp
src/x3/hobotcv_imgproc/hobotcv_front.cpp
src/x3/hobotcv_imgproc/hobotcv_single.cpp
src/x3/hobotcv_gaussian_blur.cpp
src/x3/hobotcv_gaussian_blur_imp.cpp
)
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS} ${VPS_LIBS} ${NEON_LIBS})
add_executable(example test/test_crop_resize_rotate.cpp)
target_link_libraries(example
${LINK_LIBS}
${PROJECT_NAME}
${VPS_LIBS})
add_executable(crop_example test/test_crop.cpp)
target_link_libraries(crop_example
${LINK_LIBS}
${PROJECT_NAME}
${VPS_LIBS})
add_executable(resize_example test/test_resize.cpp)
target_link_libraries(resize_example
${LINK_LIBS}
${PROJECT_NAME}
${VPS_LIBS})
add_executable(rotate_example test/test_rotate.cpp)
target_link_libraries(rotate_example
${LINK_LIBS}
${PROJECT_NAME}
${VPS_LIBS})
add_executable(pyramid_example test/test_pyramid.cpp)
target_link_libraries(pyramid_example
${LINK_LIBS}
${PROJECT_NAME}
${VPS_LIBS})
add_executable(padding_example test/test_padding.cpp)
target_link_libraries(padding_example
${LINK_LIBS}
${PROJECT_NAME})
add_executable(neon_example test/test_neon_blur.cpp)
target_link_libraries(neon_example
${LINK_LIBS}
${PROJECT_NAME}
${VPS_LIBS})
add_executable(test_gaussian_blur test/test_gaussian_blur.cpp)
target_link_libraries(test_gaussian_blur
${LINK_LIBS}
${PROJECT_NAME})
add_executable(hobotcv_benchmark
benchmark/main.cpp
benchmark/hobotcv_benchmark_node.cpp)
target_link_libraries(hobotcv_benchmark
${LINK_LIBS}
${PROJECT_NAME}
${VPS_LIBS})
ament_target_dependencies(
${PROJECT_NAME}
rclcpp
)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib>
$<INSTALL_INTERFACE:lib>)
# Install libraries
install(TARGETS ${PROJECT_NAME}
DESTINATION lib/)
# Install include files
install(
FILES include/x3/hobotcv_imgproc/hobotcv_imgproc.h
FILES include/x3/hobotcv_gaussian_blur.h
FILES include/x3/hobotcv_gaussian_blur_imp.hpp
FILES thirdparty/include/hobotcv_neon_blur.h
DESTINATION include/${PROJECT_NAME}/
)
# Install library
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/lib/libhobotcv_neon_blur.so
DESTINATION lib/)
# Install executables
install(
TARGETS example crop_example resize_example rotate_example pyramid_example padding_example test_gaussian_blur neon_example hobotcv_benchmark
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
# Install config
install(DIRECTORY
${PROJECT_SOURCE_DIR}/config/
DESTINATION lib/${PROJECT_NAME}/config/
)
install(DIRECTORY
${PROJECT_SOURCE_DIR}/launch/
DESTINATION share/${PROJECT_NAME}/launch)
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME}
PRIVATE "RCLCPP_BUILDING_LIBRARY")
install(
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
elseif(PLATFORM_X86)
add_library(${PROJECT_NAME} SHARED
src/utils.cpp
src/x86/hobotcv_imgproc/hobotcv_imgproc.cpp
# src/x86/hobotcv_imgproc/hobotcv_front.cpp
# src/x86/hobotcv_imgproc/hobotcv_single.cpp
# src/x86/hobotcv_gaussian_blur.cpp
# src/x86/hobotcv_gaussian_blur_imp.cpp
)
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS} ${VPS_LIBS} ${NEON_LIBS})
# add_executable(example test/test_crop_resize_rotate.cpp)
# target_link_libraries(example
# ${LINK_LIBS}
# ${PROJECT_NAME}
# ${VPS_LIBS})
# add_executable(crop_example test/test_crop.cpp)
# target_link_libraries(crop_example
# ${LINK_LIBS}
# ${PROJECT_NAME}
# ${VPS_LIBS})
add_executable(resize_example test/test_resize.cpp)
target_link_libraries(resize_example
${LINK_LIBS}
${PROJECT_NAME}
${VPS_LIBS})
# add_executable(rotate_example test/test_rotate.cpp)
# target_link_libraries(rotate_example
# ${LINK_LIBS}
# ${PROJECT_NAME}
# ${VPS_LIBS})
# add_executable(pyramid_example test/test_pyramid.cpp)
# target_link_libraries(pyramid_example
# ${LINK_LIBS}
# ${PROJECT_NAME}
# ${VPS_LIBS})
# add_executable(padding_example test/test_padding.cpp)
# target_link_libraries(padding_example
# ${LINK_LIBS}
# ${PROJECT_NAME})
# add_executable(neon_example test/test_neon_blur.cpp)
# target_link_libraries(neon_example
# ${LINK_LIBS}
# ${PROJECT_NAME}
# ${VPS_LIBS})
# add_executable(test_gaussian_blur test/test_gaussian_blur.cpp)
# target_link_libraries(test_gaussian_blur
# ${LINK_LIBS}
# ${PROJECT_NAME})
# add_executable(hobotcv_benchmark
# benchmark/main.cpp
# benchmark/hobotcv_benchmark_node.cpp)
# target_link_libraries(hobotcv_benchmark
# ${LINK_LIBS}
# ${PROJECT_NAME}
# ${VPS_LIBS})
ament_target_dependencies(
${PROJECT_NAME}
rclcpp
)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib>
$<INSTALL_INTERFACE:lib>)
# Install libraries
install(TARGETS ${PROJECT_NAME}
DESTINATION lib/)
install(FILES
${SYS_ROOT}/usr/lib/libopencv_world.so.3.4
DESTINATION lib/)
# Install include files
# install(
# FILES include/hobotcv_imgproc/hobotcv_imgproc.h
# FILES include/hobotcv_gaussian_blur.h
# FILES include/hobotcv_gaussian_blur_imp.hpp
# FILES thirdparty/include/hobotcv_neon_blur.h
# DESTINATION include/${PROJECT_NAME}/
# )
install(
FILES include/x86/hobotcv_imgproc/hobotcv_imgproc.h
# FILES include/x86/hobotcv_gaussian_blur.h
# FILES include/x86/hobotcv_gaussian_blur_imp.hpp
# FILES thirdparty/include/hobotcv_neon_blur.h
DESTINATION include/${PROJECT_NAME}/
)
# Install library
# install(FILES
# ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/lib/libhobotcv_neon_blur.so
# DESTINATION lib/)
# Install executables
# install(
# TARGETS example crop_example resize_example rotate_example pyramid_example padding_example test_gaussian_blur neon_example hobotcv_benchmark
# RUNTIME DESTINATION lib/${PROJECT_NAME}
# )
install(
TARGETS resize_example
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
# Install config
install(DIRECTORY
${PROJECT_SOURCE_DIR}/config/
DESTINATION lib/${PROJECT_NAME}/config/
)
install(DIRECTORY
${PROJECT_SOURCE_DIR}/launch/
DESTINATION share/${PROJECT_NAME}/launch)
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME}
PRIVATE "RCLCPP_BUILDING_LIBRARY")
install(
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
elseif(PLATFORM_Rdkultra)
add_library(${PROJECT_NAME} SHARED
src/utils.cpp
src/rdkultra/hobotcv_imgproc/hobotcv_imgproc.cpp
)
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS} ${VPS_LIBS} ${NEON_LIBS})
add_executable(resize_example test/test_resize.cpp)
target_link_libraries(resize_example
${LINK_LIBS}
${PROJECT_NAME}
${VPS_LIBS})
ament_target_dependencies(
${PROJECT_NAME}
rclcpp
)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib>
$<INSTALL_INTERFACE:lib>)
# Install libraries
install(TARGETS ${PROJECT_NAME}
DESTINATION lib/)
install(FILES
${SYS_ROOT}/usr/lib/libopencv_world.so.3.4
DESTINATION lib/)
install(
FILES include/rdkultra/hobotcv_imgproc/hobotcv_imgproc.h
DESTINATION include/${PROJECT_NAME}/
)
install(
TARGETS resize_example
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
# Install config
install(DIRECTORY
${PROJECT_SOURCE_DIR}/config/
DESTINATION lib/${PROJECT_NAME}/config/
)
install(DIRECTORY
${PROJECT_SOURCE_DIR}/launch/
DESTINATION share/${PROJECT_NAME}/launch)
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME}
PRIVATE "RCLCPP_BUILDING_LIBRARY")
install(
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
endif()
# specific order: dependents before dependencies
ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_targets(${PROJECT_NAME})
ament_package()