|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
cmake_minimum_required(VERSION 3.1) |
|
|
|
|
cmake_minimum_required(VERSION 3.12) |
|
|
|
|
|
|
|
|
|
set(CMAKE_CUDA_ARCHITECTURES 60 61 62 70 72 75 86 89 90) |
|
|
|
|
set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc) |
|
|
|
@ -10,47 +10,76 @@ set(CMAKE_CXX_STANDARD 14) |
|
|
|
|
set(CMAKE_BUILD_TYPE Release) |
|
|
|
|
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF) |
|
|
|
|
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") |
|
|
|
|
include(Function) |
|
|
|
|
|
|
|
|
|
# CUDA |
|
|
|
|
find_package(CUDA REQUIRED) |
|
|
|
|
message(STATUS "CUDA Libs: \n${CUDA_LIBRARIES}\n") |
|
|
|
|
print_var(CUDA_LIBRARIES) |
|
|
|
|
print_var(CUDA_INCLUDE_DIRS) |
|
|
|
|
get_filename_component(CUDA_LIB_DIR ${CUDA_LIBRARIES} DIRECTORY) |
|
|
|
|
message(STATUS "CUDA Headers: \n${CUDA_INCLUDE_DIRS}\n") |
|
|
|
|
print_var(CUDA_LIB_DIR) |
|
|
|
|
|
|
|
|
|
# OpenCV |
|
|
|
|
find_package(OpenCV REQUIRED) |
|
|
|
|
message(STATUS "OpenCV Libs: \n${OpenCV_LIBS}\n") |
|
|
|
|
message(STATUS "OpenCV Libraries: \n${OpenCV_LIBRARIES}\n") |
|
|
|
|
message(STATUS "OpenCV Headers: \n${OpenCV_INCLUDE_DIRS}\n") |
|
|
|
|
print_var(OpenCV_LIBS) |
|
|
|
|
print_var(OpenCV_LIBRARIES) |
|
|
|
|
print_var(OpenCV_INCLUDE_DIRS) |
|
|
|
|
|
|
|
|
|
# TensorRT |
|
|
|
|
set(TensorRT_INCLUDE_DIRS /usr/include/x86_64-linux-gnu) |
|
|
|
|
set(TensorRT_LIBRARIES /usr/lib/x86_64-linux-gnu) |
|
|
|
|
|
|
|
|
|
find_package(TensorRT REQUIRED) |
|
|
|
|
print_var(TensorRT_LIBRARIES) |
|
|
|
|
print_var(TensorRT_INCLUDE_DIRS) |
|
|
|
|
print_var(TensorRT_LIB_DIR) |
|
|
|
|
if (TensorRT_VERSION_MAJOR GREATER_EQUAL 10) |
|
|
|
|
message(STATUS "Build with -DTRT_10") |
|
|
|
|
add_definitions(-DTRT_10) |
|
|
|
|
endif () |
|
|
|
|
|
|
|
|
|
message(STATUS "TensorRT Libs: \n${TensorRT_LIBRARIES}\n") |
|
|
|
|
message(STATUS "TensorRT Headers: \n${TensorRT_INCLUDE_DIRS}\n") |
|
|
|
|
|
|
|
|
|
list(APPEND INCLUDE_DIRS |
|
|
|
|
list(APPEND ALL_INCLUDE_DIRS |
|
|
|
|
${CUDA_INCLUDE_DIRS} |
|
|
|
|
${OpenCV_INCLUDE_DIRS} |
|
|
|
|
${TensorRT_INCLUDE_DIRS} |
|
|
|
|
./include |
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
list(APPEND ALL_LIBS |
|
|
|
|
${CUDA_LIBRARIES} |
|
|
|
|
${CUDA_LIB_DIR} |
|
|
|
|
${OpenCV_LIBRARIES} |
|
|
|
|
${TensorRT_LIBRARIES} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
include_directories(${INCLUDE_DIRS}) |
|
|
|
|
list(APPEND ALL_LIB_DIRS |
|
|
|
|
${CUDA_LIB_DIR} |
|
|
|
|
${TensorRT_LIB_DIR} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
print_var(ALL_INCLUDE_DIRS) |
|
|
|
|
print_var(ALL_LIBS) |
|
|
|
|
print_var(ALL_LIB_DIRS) |
|
|
|
|
|
|
|
|
|
add_executable(${PROJECT_NAME} |
|
|
|
|
main.cpp |
|
|
|
|
include/yolov8-cls.hpp |
|
|
|
|
include/common.hpp |
|
|
|
|
|
|
|
|
|
add_executable( |
|
|
|
|
${PROJECT_NAME} |
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp |
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/yolov8-cls.hpp |
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/common.hpp |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
target_include_directories( |
|
|
|
|
${PROJECT_NAME} |
|
|
|
|
PUBLIC |
|
|
|
|
${ALL_INCLUDE_DIRS} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
target_link_directories(${PROJECT_NAME} PUBLIC ${ALL_LIBS}) |
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE nvinfer nvinfer_plugin cudart ${OpenCV_LIBS}) |
|
|
|
|
target_link_directories( |
|
|
|
|
${PROJECT_NAME} |
|
|
|
|
PUBLIC |
|
|
|
|
${ALL_LIB_DIRS} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
target_link_libraries( |
|
|
|
|
${PROJECT_NAME} |
|
|
|
|
PRIVATE |
|
|
|
|
${ALL_LIBS} |
|
|
|
|
) |
|
|
|
|