-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
64 lines (48 loc) · 1.62 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
#检查cmake版本
cmake_minimum_required(VERSION 3.5)
#项目名
project(yolov5tensorrt)
#可执行文件保存目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug)
set(CUDA_GEN_CODE "-gencode=arch=compute_86,code=sm_86")
#cuda
find_package(CUDA REQUIRED)
#自定义opencv路径
set(OpenCV_DIR /home/ls/softwares/opencv-4.5.5/build)
# find opencv
find_package(OpenCV REQUIRED)
if(NOT OpenCV_FOUND)
message(ERROR "OpenCV not found!")
endif(NOT OpenCV_FOUND)
#tensorrt
# set(TensorRT_DIR /home/ls/softwares/TensorRT-8.2.3.0)
set(TensorRT_DIR /home/ls/softwares/TensorRT)
include_directories(
${OpenCV_INCLUDE_DIRS}
${CUDA_INCLUDE_DIRS}
${TensorRT_DIR}/include
)
link_directories(
${TensorRT_DIR}/lib
/usr/local/cuda/lib64
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O0 -Wfatal-errors -pthread -w -g")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11 -O0 -Xcompiler -fPIC -g -w ${CUDA_GEN_CODE}")
# 链接子项目部件
add_subdirectory(${CMAKE_SOURCE_DIR}/src/module)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/application)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/onnxplugin)
# 链接库目录
link_directories(${CMAKE_SOURCE_DIR}/lib)
# 链接依赖库
link_libraries(module)
link_libraries(application)
link_libraries(onnxplugin)
ADD_EXECUTABLE(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} nvinfer nvonnxparser)
target_link_libraries(${PROJECT_NAME} cuda cublas cudart cudnn)
target_link_libraries(${PROJECT_NAME} pthread)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})