forked from DefTruth/lite.ai.toolkit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup_3rdparty.cmake
76 lines (65 loc) · 2.98 KB
/
setup_3rdparty.cmake
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
# 1. setup 3rd-party dependencies
message("########## Setting up 3rd-party dependencies for: ${CMAKE_CURRENT_SOURCE_DIR} ###########")
set(THIRDPARTY_SET_STATE OFF)
if (EXISTS ${THIRDPARTY_DIR} AND LITE_AI_THIRDPARTY)
message("Setting Up Custom Dependencies ...")
set(OpenCV_DIR ${THIRDPARTY_DIR}/opencv/4.5.2/x86_64/lib/cmake/opencv4)
set(OpenCV_LIBRARY_DIR ${THIRDPARTY_DIR}/opencv/4.5.2/x86_64/lib)
if (ENABLE_ONNXRUNTIME)
set(ONNXRUNTIME_DIR ${THIRDPARTY_DIR}/onnxruntime/1.7.0/x86_64)
set(ONNXRUNTIME_INCLUDE_DIR ${ONNXRUNTIME_DIR}/include)
set(ONNXRUNTIME_LIBRARY_DIR ${ONNXRUNTIME_DIR}/lib)
include_directories(${ONNXRUNTIME_INCLUDE_DIR})
link_directories(${ONNXRUNTIME_LIBRARY_DIR})
endif()
if (ENABLE_MNN)
set(MNN_DIR ${THIRDPARTY_DIR}/mnn/x86_64)
set(MNN_INCLUDE_DIR ${MNN_DIR}/include)
set(MNN_LIBRARY_DIR ${MNN_DIR}/lib)
include_directories(${MNN_INCLUDE_DIR})
link_directories(${MNN_LIBRARY_DIR})
endif()
if (ENABLE_NCNN)
set(NCNN_DIR ${THIRDPARTY_DIR}/ncnn/x86_64)
set(NCNN_INCLUDE_DIR ${NCNN_DIR}/include)
set(NCNN_LIBRARY_DIR ${NCNN_DIR}/lib)
include_directories(${NCNN_INCLUDE_DIR})
link_directories(${NCNN_LIBRARY_DIR})
endif()
if (ENABLE_TNN)
set(TNN_DIR ${THIRDPARTY_DIR}/tnn/x86_64)
set(TNN_INCLUDE_DIR ${TNN_DIR}/include)
set(TNN_LIBRARY_DIR ${TNN_DIR}/lib)
include_directories(${TNN_INCLUDE_DIR})
link_directories(${TNN_LIBRARY_DIR})
endif()
else ()
message(FATAL_ERROR "Dependencies Setting Up Error!")
endif ()
# 2. check if OpenCV is available.
if (OpenCV_FOUND)
include_directories(${OpenCV_INCLUDE_DIRS})
set(OpenCV_LIBS opencv_highgui opencv_core opencv_imgcodecs opencv_imgproc) # need only
message("=================================================================================")
message(STATUS " OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
message("=================================================================================")
else ()
# find at first time
find_package(OpenCV 4 REQUIRED)
if (OpenCV_FOUND)
include_directories(${OpenCV_INCLUDE_DIRS})
set(OpenCV_LIBS opencv_highgui opencv_core opencv_imgcodecs opencv_imgproc) # need only
message("=================================================================================")
message(STATUS " OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
message("=================================================================================")
else ()
message(FATAL_ERROR "OpenCV library not found")
endif ()
endif ()
set(THIRDPARTY_SET_STATE ON)