forked from nndeploy/nndeploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
473 lines (442 loc) · 17.3 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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
cmake_minimum_required(VERSION 3.12)
project(nndeploy)
ENABLE_LANGUAGE(ASM C CXX)
set(NNDEPLOY_MAJOR_VERSION 1)
set(NNDEPLOY_MINOR_VERSION 0)
set(NNDEPLOY_PATCH_VERSION 0)
set(NNDEPLOY_BUILD_VERSION 0)
set(NNDEPLOY_VERSION "${NNDEPLOY_MAJOR_VERSION}.${NNDEPLOY_MINOR_VERSION}.${NNDEPLOY_PATCH_VERSION}.${NNDEPLOY_BUILD_VERSION}")
include(cmake/util.cmake)
include(cmake/summary.cmake)
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
endif()
# common
nndeploy_option(ENABLE_NNDEPLOY_BUILD_SHARED "ENABLE_NNDEPLOY_BUILD_SHARED" ON)
nndeploy_option(ENABLE_NNDEPLOY_SYMBOL_HIDE "ENABLE_NNDEPLOY_SYMBOL_HIDE" OFF)
nndeploy_option(ENABLE_NNDEPLOY_COVERAGE "ENABLE_NNDEPLOY_COVERAGE" OFF)
nndeploy_option(ENABLE_NNDEPLOY_CXX11_ABI "ENABLE_NNDEPLOY_CXX11_ABI" ON)
nndeploy_option(ENABLE_NNDEPLOY_CXX14_ABI "ENABLE_NNDEPLOY_CXX14_ABI" OFF)
nndeploy_option(ENABLE_NNDEPLOY_CXX17_ABI "ENABLE_NNDEPLOY_CXX17_ABI" OFF)
nndeploy_option(ENABLE_NNDEPLOY_CXX20_ABI "ENABLE_NNDEPLOY_CXX20_ABI" OFF)
nndeploy_option(ENABLE_NNDEPLOY_OPENMP "ENABLE_NNDEPLOY_OPENMP" OFF)
nndeploy_option(ENABLE_NNDEPLOY_ADDRESS_SANTIZER "ENABLE_NNDEPLOY_ADDRESS_SANTIZER" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DOCS "ENABLE_NNDEPLOY_DOCS" OFF)
nndeploy_option(ENABLE_NNDEPLOY_TIME_PROFILER "ENABLE_NNDEPLOY_TIME_PROFILER" ON)
nndeploy_option(ENABLE_NNDEPLOY_OPENCV "ENABLE_NNDEPLOY_OPENCV" OFF)
## base
nndeploy_option(ENABLE_NNDEPLOY_BASE "ENABLE_NNDEPLOY_BASE" ON)
## thread
nndeploy_option(ENABLE_NNDEPLOY_THREAD_POOL "ENABLE_NNDEPLOY_THREAD_POOL" ON)
## cryption
nndeploy_option(ENABLE_NNDEPLOY_CRYPTION "ENABLE_NNDEPLOY_CRYPTION" OFF)
## device
nndeploy_option(ENABLE_NNDEPLOY_DEVICE "ENABLE_NNDEPLOY_DEVICE" ON)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_CPU "ENABLE_NNDEPLOY_DEVICE_CPU" ON)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_ARM "ENABLE_NNDEPLOY_DEVICE_ARM" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_X86 "ENABLE_NNDEPLOY_DEVICE_X86" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_CUDA "ENABLE_NNDEPLOY_DEVICE_CUDA" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_CUDNN "ENABLE_NNDEPLOY_DEVICE_CUDNN" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_OPENCL "ENABLE_NNDEPLOY_DEVICE_OPENCL" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_OPENGL "ENABLE_NNDEPLOY_DEVICE_OPENGL" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_METAL "ENABLE_NNDEPLOY_DEVICE_METAL" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_APPLE_NPU "ENABLE_NNDEPLOY_DEVICE_APPLE_NPU" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_HVX "ENABLE_NNDEPLOY_DEVICE_HVX" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_MTK_VPU "ENABLE_NNDEPLOY_DEVICE_MTK_VPU" OFF)
nndeploy_option(ENABLE_NNDEPLOY_DEVICE_ASCEND_CL "ENABLE_NNDEPLOY_DEVICE_ASCEND_CL" OFF)
## op
nndeploy_option(ENABLE_NNDEPLOY_OP "ENABLE_NNDEPLOY_OP" OFF)
nndeploy_option(ENABLE_NNDEPLOY_OP_NN "ENABLE_NNDEPLOY_OP_NN" OFF)
nndeploy_option(ENABLE_NNDEPLOY_OP_CV "ENABLE_NNDEPLOY_OP_CV" OFF)
nndeploy_option(ENABLE_NNDEPLOY_OP_AUDIO "ENABLE_NNDEPLOY_OP_AUDIO" OFF)
## forward
nndeploy_option(ENABLE_NNDEPLOY_FORWARD "ENABLE_NNDEPLOY_FORWARD" OFF)
## inference
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE "ENABLE_NNDEPLOY_INFERENCE" ON)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_TENSORRT "ENABLE_NNDEPLOY_INFERENCE_TENSORRT" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_OPENVINO "ENABLE_NNDEPLOY_INFERENCE_OPENVINO" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_COREML "ENABLE_NNDEPLOY_INFERENCE_COREML" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_TFLITE "ENABLE_NNDEPLOY_INFERENCE_TFLITE" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_ONNXRUNTIME "ENABLE_NNDEPLOY_INFERENCE_ONNXRUNTIME" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_NCNN "ENABLE_NNDEPLOY_INFERENCE_NCNN" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_TNN "ENABLE_NNDEPLOY_INFERENCE_TNN" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_MNN "ENABLE_NNDEPLOY_INFERENCE_MNN" OFF)
nndeploy_option(ENABLE_NNDEPLOY_AICOMPILER_TVM "ENABLE_NNDEPLOY_INFERENCE_TVM" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_PADDLELITE "ENABLE_NNDEPLOY_INFERENCE_PADDLELITE" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_RKNN_TOOLKIT_1 "ENABLE_NNDEPLOY_INFERENCE_RKNN_TOOKIT_1" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_RKNN_TOOLKIT_2 "ENABLE_NNDEPLOY_INFERENCE_RKNN_TOOKIT_2" OFF)
nndeploy_option(ENABLE_NNDEPLOY_INFERENCE_ASCEND_CL "ENABLE_NNDEPLOY_INFERENCE_ASCEND_CL" OFF)
## dag
nndeploy_option(ENABLE_NNDEPLOY_DAG "ENABLE_NNDEPLOY_DAG" ON)
## model
nndeploy_option(ENABLE_NNDEPLOY_MODEL "ENABLE_NNDEPLOY_MODEL" ON)
## test
nndeploy_option(ENABLE_NNDEPLOY_TEST "ENABLE_NNDEPLOY_TEST" OFF)
## demo
nndeploy_option(ENABLE_NNDEPLOY_DEMO "ENABLE_NNDEPLOY_DEMO" OFF)
# print option
print_summary()
# set
set(ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# install path
set(NNDEPLOY_INSTALL_PATH ${ROOT_PATH}/build/install)
if(ENABLE_NNDEPLOY_BUILD_SHARED)
set(NNDEPLOY_INSTALL_TYPE LIBRARY)
else()
set(NNDEPLOY_INSTALL_TYPE ARCHIVE)
endif()
set(CMAKE_INSTALL_PREFIX ${NNDEPLOY_INSTALL_PATH})
set(NNDEPLOY_INSTALL_LIB_PATH ${NNDEPLOY_INSTALL_PATH}/lib)
set(NNDEPLOY_INSTALL_BIN_PATH ${NNDEPLOY_INSTALL_PATH}/bin)
set(EXECUTABLE_OUTPUT_PATH ${ROOT_PATH}/build)
# build type
if(ENABLE_NNDEPLOY_BUILD_SHARED)
set(NNDEPLOY_LIB_TYPE SHARED)
else()
set(NNDEPLOY_LIB_TYPE STATIC)
endif()
# define
if(CMAKE_BUILD_TYPE MATCHES "Debug")
add_definitions(-DNNDEPLOY_DEBUG)
endif()
if(${ENABLE_NNDEPLOY_DEVICE_ARM} MATCHES "OFF")
else()
add_definitions(-DENABLE_NNDEPLOY_DEVICE_ARM)
endif()
if(${ENABLE_NNDEPLOY_DEVICE_X86} MATCHES "OFF")
else()
add_definitions(-DENABLE_NNDEPLOY_DEVICE_X86)
endif()
if(${ENABLE_NNDEPLOY_TIME_PROFILER} MATCHES "OFF")
else()
add_definitions(-DENABLE_NNDEPLOY_TIME_PROFILER)
endif()
if(${ENABLE_NNDEPLOY_OPENCV} MATCHES "OFF")
else()
add_definitions(-DENABLE_NNDEPLOY_OPENCV)
endif()
# general
set(NNDEPLOY_LIB_PREFIX "lib")
set(NNDEPLOY_LIB_SUFFIX ".so")
if(CMAKE_SYSTEM_NAME MATCHES "^Android")
set(SYSTEM.Android 1)
elseif(CMAKE_SYSTEM_NAME MATCHES "^Linux")
set(SYSTEM.Linux 1)
elseif(CMAKE_SYSTEM_NAME MATCHES "^Darwin")
set(SYSTEM.Darwin 1)
set(NNDEPLOY_LIB_SUFFIX ".dylib")
elseif(CMAKE_SYSTEM_NAME MATCHES "^iOS")
set(SYSTEM.iOS 1)
elseif(CMAKE_SYSTEM_NAME MATCHES "^Windows")
set(SYSTEM.Windows 1)
set(NNDEPLOY_LIB_PREFIX "")
set(NNDEPLOY_LIB_SUFFIX ".lib")
endif()
if(SYSTEM.Windows AND ENABLE_NNDEPLOY_BUILD_SHARED)
add_definitions(-DENABLE_NNDEPLOY_BUILDING_DLL)
endif()
if(!SYSTEM.Windows)
# you must have return sentence for un-void function
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type")
endif()
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
if(ENABLE_NNDEPLOY_OPENMP)
FIND_PACKAGE(OpenMP REQUIRED)
if(OPENMP_FOUND)
add_definitions(-DENABLE_NNDEPLOY_OPENMP)
if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
include_directories(${OpenMP_C_INCLUDE_DIRS} ${OpenMP_CXX_INCLUDE_DIRS})
if(${ANDROID_NDK_MAJOR})
if(${ANDROID_NDK_MAJOR} GREATER 20)
else()
link_libraries(${OpenMP_C_LIBRARIES} ${OpenMP_CXX_LIBRARIES})
endif()
else()
link_libraries(${OpenMP_C_LIBRARIES} ${OpenMP_CXX_LIBRARIES})
endif()
endif()
else()
error("OpenMP Not Found.")
endif()
endif()
if(ENABLE_NNDEPLOY_CXX20_ABI)
set(CMAKE_CXX_STANDARD 20)
set(ENABLE_NNDEPLOY_CXX17_ABI OFF)
set(ENABLE_NNDEPLOY_CXX14_ABI OFF)
set(ENABLE_NNDEPLOY_CXX11_ABI OFF)
endif()
if(ENABLE_NNDEPLOY_CXX17_ABI)
set(CMAKE_CXX_STANDARD 17)
set(ENABLE_NNDEPLOY_CXX14_ABI OFF)
set(ENABLE_NNDEPLOY_CXX11_ABI OFF)
endif()
if(ENABLE_NNDEPLOY_CXX14_ABI)
set(CMAKE_CXX_STANDARD 14)
set(ENABLE_NNDEPLOY_CXX11_ABI OFF)
endif()
if(ENABLE_NNDEPLOY_CXX11_ABI)
set(CMAKE_CXX_STANDARD 11)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(ENABLE_NNDEPLOY_DEVICE_METAL OR ENABLE_NNDEPLOY_DEVICE_APPLE_NPU)
# compile the file according to file type
# add_compile_nndeploy_options(-x objective-c++)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-arc -Wno-shorten-64-to-32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc -Wno-shorten-64-to-32 -Wno-null-character")
set(CMAKE_OBJCXX_FLAGS "${CMAKE_OBJCXX_FLAGS} -x objective-c++ -fobjc-arc -Wno-shorten-64-to-32 -Wno-null-character")
endif()
if(SYSTEM.Linux AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm" AND ANDROID_API_LEVAL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_C99_MATH_TR1")
add_definitions(-D__ANDROID_API__=${ANDROID_API_LEVAL})
endif()
if(ENABLE_NNDEPLOY_COVERAGE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -coverage -lgcov")
endif()
endif()
if (ENABLE_NNDEPLOY_ADDRESS_SANTIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()
# include
include_directories(include)
include_directories(source)
include_directories(third_party)
# make
set(NNDEPLOY_SOURCE)
set(NNDEPLOY_OBJECT)
set(NNDEPLOY_BINARY nndeploy)
set(NNDEPLOY_DIRECTORY nndeploy)
set(NNDEPLOY_DEPEND_LIBRARY)
set(NNDEPLOY_SYSTEM_LIBRARY)
set(NNDEPLOY_THIRD_PARTY_LIBRARY)
# nndeploy third party lib
include(${ROOT_PATH}/cmake/nndeploy.cmake)
# nndeploy source
## attention GLOB or GLOB_RECURSE
if(ENABLE_NNDEPLOY_BASE)
file(GLOB_RECURSE BASE_SOURCE
"${ROOT_PATH}/include/nndeploy/base/*.h"
"${ROOT_PATH}/include/nndeploy/base/*.hpp"
"${ROOT_PATH}/source/nndeploy/base/*.cc"
)
set(NNDEPLOY_SOURCE ${NNDEPLOY_SOURCE} ${BASE_SOURCE})
endif()
if(ENABLE_NNDEPLOY_THREAD_POOL)
file(GLOB_RECURSE THREAD_POOL_SOURCE
"${ROOT_PATH}/include/nndeploy/thread_pool/*.h"
"${ROOT_PATH}/source/nndeploy/thread_pool/*.cc"
)
set(NNDEPLOY_SOURCE ${NNDEPLOY_SOURCE} ${THREAD_POOL_SOURCE})
endif()
if(ENABLE_NNDEPLOY_CRYPTION)
file(GLOB CRYPTION_SOURCE
"${ROOT_PATH}/include/nndeploy/cryption/*.h"
"${ROOT_PATH}/source/nndeploy/cryption/*.cc"
)
set(NNDEPLOY_SOURCE ${NNDEPLOY_SOURCE} ${CRYPTION_SOURCE})
endif()
if(ENABLE_NNDEPLOY_DEVICE)
file(GLOB DEVICE_SOURCE
"${ROOT_PATH}/include/nndeploy/device/*.h"
"${ROOT_PATH}/source/nndeploy/device/*.cc"
)
if (ENABLE_NNDEPLOY_DEVICE_CPU)
file(GLOB_RECURSE DEVICE_CPU_SOURCE
"${ROOT_PATH}/include/nndeploy/device/cpu/*.h"
"${ROOT_PATH}/source/nndeploy/device/cpu/*.cc"
)
set(DEVICE_SOURCE ${DEVICE_SOURCE} ${DEVICE_CPU_SOURCE})
endif()
if (ENABLE_NNDEPLOY_DEVICE_X86)
file(GLOB_RECURSE DEVICE_X86_SOURCE
"${ROOT_PATH}/include/nndeploy/device/x86/*.h"
"${ROOT_PATH}/source/nndeploy/device/x86/*.cc"
)
set(DEVICE_SOURCE ${DEVICE_SOURCE} ${DEVICE_X86_SOURCE})
endif()
if (ENABLE_NNDEPLOY_DEVICE_ARM)
file(GLOB_RECURSE DEVICE_ARM_SOURCE
"${ROOT_PATH}/include/nndeploy/device/arm/*.h"
"${ROOT_PATH}/source/nndeploy/device/arm/*.cc"
)
set(DEVICE_SOURCE ${DEVICE_SOURCE} ${DEVICE_ARM_SOURCE})
endif()
if (ENABLE_NNDEPLOY_DEVICE_CUDA)
file(GLOB_RECURSE DEVICE_CUDA_SOURCE
"${ROOT_PATH}/include/nndeploy/device/cuda/*.h"
"${ROOT_PATH}/source/nndeploy/device/cuda/*.cc"
)
set(DEVICE_SOURCE ${DEVICE_SOURCE} ${DEVICE_CUDA_SOURCE})
endif()
if (ENABLE_NNDEPLOY_DEVICE_ASCEND_CL)
file(GLOB_RECURSE DEVICE_ASCEND_CL_SOURCE
"${ROOT_PATH}/include/nndeploy/device/ascend_cl/*.h"
"${ROOT_PATH}/source/nndeploy/device/ascend_cl/*.cc"
)
set(DEVICE_SOURCE ${DEVICE_SOURCE} ${DEVICE_ASCEND_CL_SOURCE})
endif()
set(NNDEPLOY_SOURCE ${NNDEPLOY_SOURCE} ${DEVICE_SOURCE})
endif()
if(ENABLE_NNDEPLOY_OP)
file(GLOB OP_SOURCE
"${ROOT_PATH}/include/nndeploy/op/*.h"
"${ROOT_PATH}/source/nndeploy/op/*.cc"
)
set(NNDEPLOY_SOURCE ${NNDEPLOY_SOURCE} ${OP_SOURCE})
endif()
if(ENABLE_NNDEPLOY_FORWARD)
file(GLOB_RECURSE FORWARD_SOURCE
"${ROOT_PATH}/include/nndeploy/forward/*.h"
"${ROOT_PATH}/source/nndeploy/forward/*.cc"
)
set(NNDEPLOY_SOURCE ${NNDEPLOY_SOURCE} ${FORWARD_SOURCE})
endif()
if(ENABLE_NNDEPLOY_INFERENCE)
file(GLOB INFERENCE_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/*.h"
"${ROOT_PATH}/source/nndeploy/inference/*.cc"
)
if (ENABLE_NNDEPLOY_INFERENCE_TENSORRT)
file(GLOB_RECURSE INFERENCE_TENSORRT_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/tensorrt/*.h"
"${ROOT_PATH}/source/nndeploy/inference/tensorrt/*.cc"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_TENSORRT_SOURCE})
endif()
if (ENABLE_NNDEPLOY_INFERENCE_TNN)
file(GLOB_RECURSE INFERENCE_TNN_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/tnn/*.h"
"${ROOT_PATH}/source/nndeploy/inference/tnn/*.cc"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_TNN_SOURCE})
endif()
if (ENABLE_NNDEPLOY_INFERENCE_MNN)
file(GLOB_RECURSE INFERENCE_MNN_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/mnn/*.h"
"${ROOT_PATH}/source/nndeploy/inference/mnn/*.cc"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_MNN_SOURCE})
endif()
if (ENABLE_NNDEPLOY_INFERENCE_OPENVINO)
file(GLOB_RECURSE INFERENCE_OPENVINO_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/openvino/*.h"
"${ROOT_PATH}/source/nndeploy/inference/openvino/*.cc"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_OPENVINO_SOURCE})
endif()
if (ENABLE_NNDEPLOY_INFERENCE_COREML)
file(GLOB_RECURSE INFERENCE_COREML_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/coreml/*.h"
"${ROOT_PATH}/source/nndeploy/inference/coreml/*.cc"
"${ROOT_PATH}/source/nndeploy/inference/coreml/*.mm"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_COREML_SOURCE})
endif()
if (ENABLE_NNDEPLOY_INFERENCE_ONNXRUNTIME)
file(GLOB_RECURSE INFERENCE_ONNXRUNTIME_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/onnxruntime/*.h"
"${ROOT_PATH}/source/nndeploy/inference/onnxruntime/*.cc"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_ONNXRUNTIME_SOURCE})
endif()
if (ENABLE_NNDEPLOY_INFERENCE_TFLITE)
file(GLOB_RECURSE INFERENCE_TFLITE_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/tflite/*.h"
"${ROOT_PATH}/source/nndeploy/inference/tflite/*.cc"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_TFLITE_SOURCE})
endif()
if (ENABLE_NNDEPLOY_INFERENCE_NCNN)
file(GLOB_RECURSE INFERENCE_NCNN_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/ncnn/*.h"
"${ROOT_PATH}/source/nndeploy/inference/ncnn/*.cc"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_NCNN_SOURCE})
endif()
if (ENABLE_NNDEPLOY_INFERENCE_PADDLELITE)
file(GLOB_RECURSE INFERENCE_PADDLELITE_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/paddlelite/*.h"
"${ROOT_PATH}/source/nndeploy/inference/paddlelite/*.cc"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_PADDLELITE_SOURCE})
endif()
if (ENABLE_NNDEPLOY_INFERENCE_RKNN)
file(GLOB_RECURSE INFERENCE_RKNN_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/rknn/*.h"
"${ROOT_PATH}/source/nndeploy/inference/rknn/*.cc"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_RKNN_SOURCE})
endif()
if (ENABLE_NNDEPLOY_INFERENCE_ASCEND_CL)
file(GLOB_RECURSE INFERENCE_ASCEND_CL_SOURCE
"${ROOT_PATH}/include/nndeploy/inference/ascend_cl/*.h"
"${ROOT_PATH}/source/nndeploy/inference/ascend_cl/*.cc"
)
set(INFERENCE_SOURCE ${INFERENCE_SOURCE} ${INFERENCE_ASCEND_CL_SOURCE})
endif()
set(NNDEPLOY_SOURCE ${NNDEPLOY_SOURCE} ${INFERENCE_SOURCE})
endif()
if(ENABLE_NNDEPLOY_DAG)
file(GLOB_RECURSE DAG_SOURCE
"${ROOT_PATH}/include/nndeploy/dag/*.h"
"${ROOT_PATH}/include/nndeploy/dag/*.hpp"
"${ROOT_PATH}/source/nndeploy/dag/*.cc"
)
set(NNDEPLOY_SOURCE ${NNDEPLOY_SOURCE} ${DAG_SOURCE})
endif()
if(ENABLE_NNDEPLOY_MODEL)
set(MODEL_SOURCE)
include(${ROOT_PATH}/source/nndeploy/model/config.cmake)
# message(STATUS "MODEL_SOURCE: ${MODEL_SOURCE}")
set(NNDEPLOY_SOURCE ${NNDEPLOY_SOURCE} ${MODEL_SOURCE})
endif()
# nndeploy
## TARGET
add_library(${NNDEPLOY_BINARY} ${NNDEPLOY_LIB_TYPE} ${NNDEPLOY_SOURCE} ${NNDEPLOY_OBJECT})
## DIRECTORY
set_property(TARGET ${NNDEPLOY_BINARY} PROPERTY FOLDER ${NNDEPLOY_DIRECTORY})
## DEPEND_LIBRARY
target_link_libraries(${NNDEPLOY_BINARY} ${NNDEPLOY_DEPEND_LIBRARY})
## SYSTEM_LIBRARY
target_link_libraries(${NNDEPLOY_BINARY} ${NNDEPLOY_SYSTEM_LIBRARY})
## THIRD_PARTY_LIBRARY
target_link_libraries(${NNDEPLOY_BINARY} ${NNDEPLOY_THIRD_PARTY_LIBRARY})
## install
if(SYSTEM.Windows)
install(TARGETS ${NNDEPLOY_BINARY} ${NNDEPLOY_INSTALL_TYPE} DESTINATION ${NNDEPLOY_INSTALL_PATH})
else()
install(TARGETS ${NNDEPLOY_BINARY} ${NNDEPLOY_INSTALL_TYPE} DESTINATION ${NNDEPLOY_INSTALL_LIB_PATH})
endif()
# GFLAGS
set(ENABLE_NNDEPLOY_GFLAGS)
if(ENABLE_NNDEPLOY_TEST)
set(ENABLE_NNDEPLOY_GFLAGS ON)
endif()
if (ENABLE_NNDEPLOY_DEMO)
set(ENABLE_NNDEPLOY_GFLAGS ON)
endif()
if(ENABLE_NNDEPLOY_GFLAGS)
add_subdirectory(third_party/gflags)
get_target_property(GFLAGS_INCLUDE_DIRS gflags INTERFACE_INCLUDE_DIRECTORIES)
include_directories(BEFORE "${GFLAGS_INCLUDE_DIRS}")
endif()
# nndeploy_test
if(ENABLE_NNDEPLOY_TEST)
include(${ROOT_PATH}/test/config.cmake)
endif()
# nndeploy_demo
if (ENABLE_NNDEPLOY_DEMO)
include(${ROOT_PATH}/demo/config.cmake)
endif()