-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
72 lines (58 loc) · 1.49 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
IF(POLICY CMP0046)
CMAKE_POLICY(SET CMP0046 NEW)
ENDIF()
IF(POLICY CMP0054)
CMAKE_POLICY(SET CMP0054 NEW)
ENDIF()
#find package
FIND_PACKAGE(OpenCV REQUIRED)
FIND_PACKAGE(CUDA REQUIRED)
#define platform4
ADD_DEFINITIONS("-D__X86_64__")
#c14
ADD_DEFINITIONS("-std=c++14")
SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-std=c++14;
-gencode arch=compute_30,code=sm_30;
-gencode arch=compute_32,code=sm_32;
-gencode arch=compute_53,code=sm_53;
-gencode arch=compute_61,code=sm_61;
-gencode arch=compute_62,code=sm_62;
-gencode arch=compute_70,code=sm_70;)
#add src
FILE(GLOB_RECURSE SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cu"
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
)
#add include
SET(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
LIST(APPEND INCLUDE_DIR_LISTS
${OpenCV_INCLUDE_DIRS}
${CUDA_INCLUDE_DIRS}
${INCLUDE_DIR}/TensorRT-5.0.2.6)
INCLUDE_DIRECTORIES(${INCLUDE_DIR_LISTS})
#add library
SET(LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
LINK_DIRECTORIES(${LIBS_DIR})
LINK_DIRECTORIES(${LIBS_DIR}/TensorRT-5.0.2.6)
LIST(APPEND TENSORRT_LIBS
nvcaffe_parser
nvonnxparser
nvinfer
nvinfer_plugin
nvparsers)
LIST(APPEND OPENCV_LIBS
opencv_core
opencv_highgui
opencv_videoio
opencv_imgcodecs
opencv_imgproc)
LIST(APPEND LIB_LIST
${CUDA_LIBRARIES}
${TENSORRT_LIBS}
${OPENCV_LIBS}
pthread)
#generate binary
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
CUDA_ADD_EXECUTABLE(tensorrt-custom ${SRCS})
TARGET_LINK_LIBRARIES(tensorrt-custom ${LIB_LIST})