You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.3 KiB
65 lines
2.3 KiB
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
|
|
project(YOLOv8CPP)
|
|
|
|
SET(CMAKE_CXX_STANDARD 17)
|
|
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
# SET (OpenCV_DIR your/path/to/opencv/build/x64/vc16/lib) # opencv lib root
|
|
# SET (OpenCV_BIN_DIR your/path/to/opencv/build/x64/vc16/bin) #opencv bin root
|
|
|
|
# SET (OpenCV_DEBUG_DLL_FILENAME opencv_world480d.dll) # change filenames
|
|
# SET (OpenCV_RELEASE_DLL_FILENAME opencv_world480.dll) # change filenames
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
|
SET (ONNXRUNTIME_DIR "${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime/onnxruntime-linux-x64-gpu-1.18.1")
|
|
|
|
FIND_PACKAGE(OpenCV REQUIRED)
|
|
set(CMAKE_BUILD_TYPE Debug)
|
|
# --- Configure your project files ---
|
|
include_directories(include) # Include your header files directory
|
|
|
|
# Recursively collect all source files under 'src' directory
|
|
file(GLOB_RECURSE CURR_SOURCES src/*.cpp)
|
|
|
|
# Create the executable
|
|
add_executable(YOLOv8CPP ${CURR_SOURCES})
|
|
|
|
target_compile_features(YOLOv8CPP PRIVATE cxx_std_17)
|
|
|
|
TARGET_INCLUDE_DIRECTORIES(YOLOv8CPP PRIVATE "${ONNXRUNTIME_DIR}/include")
|
|
|
|
|
|
TARGET_LINK_LIBRARIES(YOLOv8CPP ${OpenCV_LIBS})
|
|
|
|
if (WIN32)
|
|
TARGET_LINK_LIBRARIES(YOLOv8CPP "${ONNXRUNTIME_DIR}/lib/onnxruntime.lib")
|
|
|
|
# some changes to the original version:
|
|
# copy onnxruntime dll
|
|
add_custom_command(TARGET YOLOv8CPP POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
"${ONNXRUNTIME_DIR}/lib/onnxruntime.dll"
|
|
"$<TARGET_FILE_DIR:YOLOv8CPP>"
|
|
)
|
|
# copy opencv
|
|
#[[ add_custom_command(TARGET YOLOv8CPP POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_differentdpkg -L libcv2
|
|
"${OpenCV_DIR}/${OpenCV_DLL_FILENAME}"
|
|
"$<TARGET_FILE_DIR:YOLOv8CPP>"
|
|
)]]
|
|
add_custom_command(TARGET YOLOv8CPP POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
"${OpenCV_BIN_DIR}/${OpenCV_DEBUG_DLL_FILENAME}"
|
|
"$<TARGET_FILE_DIR:YOLOv8CPP>"
|
|
)
|
|
# add release
|
|
add_custom_command(TARGET YOLOv8CPP POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
"${OpenCV_BIN_DIR}/${OpenCV_RELEASE_DLL_FILENAME}"
|
|
"$<TARGET_FILE_DIR:YOLOv8CPP>"
|
|
)
|
|
|
|
endif(WIN32)
|
|
|
|
if (UNIX)
|
|
TARGET_LINK_LIBRARIES(YOLOv8CPP "${ONNXRUNTIME_DIR}/lib/libonnxruntime.so")
|
|
endif(UNIX)
|