-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
88 lines (75 loc) · 3.06 KB
/
Copy pathCMakeLists.txt
File metadata and controls
88 lines (75 loc) · 3.06 KB
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
cmake_minimum_required(VERSION 3.16)
project(PoseEstimation LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ==============================================================================
# Dependencies
# ==============================================================================
# OpenCV: Required for image processing and visualization
# Path is provided via CMakePresets.json (OpenCV_DIR variable)
find_package(OpenCV REQUIRED)
# ONNX Runtime: Required for model inference
# ONNXRUNTIME_ROOT is provided via CMakePresets.json
find_library(ONNXRT_LIBRARY
NAMES onnxruntime
HINTS "${ONNXRUNTIME_ROOT}/lib"
REQUIRED
)
set(ONNXRT_INCLUDE_DIR "${ONNXRUNTIME_ROOT}/include")
# Log dependency paths for debugging
message(STATUS "OpenCV version: ${OpenCV_VERSION}")
message(STATUS "OpenCV directory: ${OpenCV_DIR}")
message(STATUS "ONNX Runtime: ${ONNXRUNTIME_ROOT}")
message(STATUS "ONNX Runtime library: ${ONNXRT_LIBRARY}")
# ==============================================================================
# Executable Target
# ==============================================================================
add_executable(PoseEstimation
src/main.cpp
src/onnx_engine.cpp
src/preprocess_letterbox.cpp
src/yolo_pose_postprocess.cpp
src/visualize_results.cpp
src/input_handler.cpp
src/pipeline.cpp
)
# Include paths
target_include_directories(PoseEstimation PRIVATE
${OpenCV_INCLUDE_DIRS}
${ONNXRT_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/include
)
# Link libraries
target_link_libraries(PoseEstimation
PRIVATE
${OpenCV_LIBS}
${ONNXRT_LIBRARY}
)
# ==============================================================================
# Platform-Specific Configuration (Windows)
# ==============================================================================
if(WIN32)
# Copy data assets (models, test images) to output directory
file(COPY "${CMAKE_SOURCE_DIR}/models" DESTINATION "${CMAKE_BINARY_DIR}")
file(COPY "${CMAKE_SOURCE_DIR}/data" DESTINATION "${CMAKE_BINARY_DIR}")
# Copy ONNX Runtime DLLs to output directory
# without modifying system PATH
add_custom_command(TARGET PoseEstimation POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${ONNXRUNTIME_ROOT}/lib/onnxruntime.dll"
"$<TARGET_FILE_DIR:PoseEstimation>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${ONNXRUNTIME_ROOT}/lib/onnxruntime_providers_cuda.dll"
"$<TARGET_FILE_DIR:PoseEstimation>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${ONNXRUNTIME_ROOT}/lib/onnxruntime_providers_shared.dll"
"$<TARGET_FILE_DIR:PoseEstimation>"
COMMENT "Copying ONNX Runtime DLLs to output directory"
)
# Configure Visual Studio debugger environment
# Adds OpenCV and cuDNN paths to PATH when running from VS (F5)
# CUDNN_BIN_DIR is provided via CMakePresets.json
set_target_properties(PoseEstimation PROPERTIES
VS_DEBUGGER_ENVIRONMENT "PATH=${ONNXRUNTIME_ROOT}/lib;${CUDNN_BIN_DIR};$ENV{PATH}"
)
endif()