-
Notifications
You must be signed in to change notification settings - Fork 34
/
CMakeLists.txt
65 lines (54 loc) · 1.72 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
cmake_minimum_required(VERSION 3.12)
project(depth-anything-tensorrt)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
# Add source files
set(SOURCES
main.cpp
utils.cpp
depth_anything.cpp
# ... add more source files here if needed
)
# Add headers
set(HEADERS
utils.h
depth_anything.h
# ... add more header files here if needed
)
# Find and include CUDA
find_package(CUDA REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
# Find and include OpenCV
set(OpenCV_DIR "D:\\Utils\\opencv\\opencv49_cpu\\build")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
# Set TensorRT path if not set in environment variables
set(TENSORRT_DIR "D:\\Utils\\TensorRT-10.0.1.6")
# Include TensorRT
include_directories(${TENSORRT_DIR}/include)
link_directories(${TENSORRT_DIR}/lib)
# Read TensorRT version
file(STRINGS "${TENSORRT_DIR}/include/NvInferVersion.h" tensorrt_version REGEX "#define NV_TENSORRT_MAJOR +[0-9]+")
string(REGEX MATCH "[0-9]+" tensorrt_version_major ${tensorrt_version})
# Check TensorRT version and set library accordingly
if (WIN32)
if (tensorrt_version_major EQUAL 10)
set(TENSORRT_LIBS nvinfer_10 nvinfer_plugin_10 nvonnxparser_10)
else()
set(TENSORRT_LIBS nvinfer nvinfer_plugin nvparsers nvonnxparser)
endif()
else()
if (tensorrt_version_major EQUAL 10)
set(TENSORRT_LIBS nvinfer nvinfer_plugin nvonnxparser)
else()
set(TENSORRT_LIBS nvinfer nvinfer_plugin nvparsers nvonnxparser)
endif()
endif()
# Add executable
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
# Link libraries
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
${CUDA_LIBRARIES}
${TENSORRT_LIBS}
)