-
Notifications
You must be signed in to change notification settings - Fork 212
/
CMakeLists.txt
114 lines (100 loc) · 4.17 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
#[[
prepare in advance:
1. OpenCV >= 4.6
2. Gstreamer >= 1.14.5
3. CUDA, TensorRT, PADDLE and others for optional
]]
cmake_minimum_required(VERSION 3.10)
project(video_pipe VERSION 1.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fPIC -w -fdiagnostics-color=always -pthread")
# save all libs(including third_party's) to 'libs'
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/libs)
# optional for build, modify values when configure the project using 'cmake -DVP_WITH_CUDA=OFF ..'
option(VP_WITH_CUDA "prepared CUDA or not?" OFF)
option(VP_WITH_TRT "prepared TensorRT or not?" OFF)
option(VP_WITH_PADDLE "prepared PaddlePaddle or not?" OFF)
option(VP_WITH_KAFKA "prepared Kafka or not?" OFF)
option(VP_BUILD_COMPLEX_SAMPLES "build complex samples or not? (maybe source code not provided)" OFF)
# OpenCV required
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS})
# Gstreamer required
include(FindPkgConfig)
pkg_check_modules(GST REQUIRED gstreamer-1.0)
pkg_check_modules(GSTAPP REQUIRED gstreamer-app-1.0)
pkg_check_modules(GST_RTSP REQUIRED gstreamer-rtsp-server-1.0)
message(STATUS "GStreamer library status:")
message(STATUS " version: ${GST_VERSION}")
message(STATUS " libraries: ${GST_LIBRARIES} ${GSTAPP_LIBRARIES} ${GST_RTSP_LIBRARIES}")
message(STATUS " include path: ${GST_INCLUDE_DIRS}")
include_directories(${GST_INCLUDE_DIRS})
set (GST_DEPEND_LIBS ${GST_LIBRARIES} ${GSTAPP_LIBRARIES} ${GST_RTSP_LIBRARIES})
# collect dependent libs for videopipe
list(APPEND VP_DEPEND_LIBS ${OpenCV_LIBS} ${GST_DEPEND_LIBS} stdc++fs)
# optional for CUDA
if(VP_WITH_CUDA) # CUDA enabled
add_definitions(-DVP_WITH_CUDA)
endif()
# optional for TensorRT
if(VP_WITH_TRT) # TensorRT enabled
add_definitions(-DVP_WITH_TRT)
set(VP_BUILD_FROM ON) # set flag for sub project
set(VP_TRT_LIB_PATH "")
set(VP_TRT_INC_PATH "")
# trt_vehicle
message("-------------start build trt_vehicle--------------")
add_subdirectory(third_party/trt_vehicle)
list(APPEND VP_DEPEND_LIBS trt_vehicle)
link_directories(${VP_TRT_LIB_PATH})
message(STATUS "TensorRT library status:")
message(STATUS " include path: ${VP_TRT_INC_PATH}")
message(STATUS " library path: ${VP_TRT_LIB_PATH}")
message("--------------end build trt_vehicle---------------")
# trt_yolov8
message("-------------start build trt_yolov8--------------")
add_subdirectory(third_party/trt_yolov8)
list(APPEND VP_DEPEND_LIBS trt_yolov8)
message("--------------end build trt_yolov8---------------")
endif()
# optional for PaddlePaddle
if(VP_WITH_PADDLE) # PaddlePaddle enabled
add_definitions(-DVP_WITH_PADDLE)
set(VP_BUILD_FROM ON) # set flag for sub project
set(VP_PADDLE_LIB_PATH "")
set(VP_PADDLE_INC_PATH "")
message("-------------start build paddle_ocr--------------")
add_subdirectory(third_party/paddle_ocr) # build paddle_ocr
list(APPEND VP_DEPEND_LIBS paddle_ocr)
link_directories(${VP_PADDLE_LIB_PATH})
message(STATUS "PaddlePaddle library status:")
message(STATUS " include path: ${VP_PADDLE_INC_PATH}")
message(STATUS " library path: ${VP_PADDLE_LIB_PATH}")
message("--------------end build paddle_ocr---------------")
endif()
# optional for Kafka
if(VP_WITH_KAFKA)
add_definitions(-DVP_WITH_KAFKA)
list(APPEND VP_DEPEND_LIBS rdkafka++)
endif()
# tinyexpr
message("-------------start build tinyexpr--------------")
add_subdirectory(third_party/tinyexpr)
list(APPEND VP_DEPEND_LIBS tinyexpr)
message("--------------end build tinyexpr---------------")
# collect source files for videopipe
file(GLOB_RECURSE NODES "nodes/*.cpp")
file(GLOB_RECURSE OBJECTS "objects/*.cpp")
file(GLOB_RECURSE UTILS "utils/*.cpp")
#...#
list(APPEND VP_CPPS_SOURCES ${NODES} ${OBJECTS} ${UTILS})
# build for videopipe
add_library(${PROJECT_NAME} SHARED ${VP_CPPS_SOURCES})
target_link_libraries(${PROJECT_NAME} ${VP_DEPEND_LIBS})
# build for samples
add_subdirectory(samples)