Skip to content

Commit

Permalink
update cmakelists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
enazoe committed Nov 13, 2020
1 parent 07946cd commit 90022af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ api/
*.pt
*.onnx
.ipynb_checkpoints
*.idea
37 changes: 15 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
cmake_minimum_required(VERSION 3.1)
project(yolo-trt)

file(GLOB_RECURSE sources modules/*.hpp modules/*.cpp modules/*.h modules/*.cu extra/*.h)
add_executable(yolo-trt samples/sample_detector.cpp)
project(yolo-trt VERSION 1.0)
enable_language(CUDA)

set(CMAKE_CXX_COMPILIER "/usr/bin/g++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3 -Wno-write-strings")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,$ORIGIN")

#cuda
#export PATH=/usr/local/cuda-11.0/bin:$PATH
#include_directories(/usr/local/cuda/include)
#link_directories(/usr/local/cuda/lib64)
find_package(CUDA REQUIRED)

message("-- CUDA version:${CUDA_VERSION}")

if(CUDA_VERSION_MAJOR GREATER 9)
message("-- CUDA ${CUDA_VERSION_MAJOR} detected")
set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
)
endif()

#opencv
#set(OpenCV_DIR /opt/opencv-4.1.2/share/OpenCV)
find_package(OpenCV REQUIRED)
if(Opencv_FOUND)
message("found opencv")
endif()

#generate detector lib
cuda_add_library(detector SHARED ${sources})
target_include_directories(detector PRIVATE extra/ modules/ ${OpenCV_INCLUDE_DIRS} ${CUDA_TOOLKIT_ROOT_DIR}/include ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
#detector lib (cuda)
file(GLOB_RECURSE sources modules/*.hpp modules/*.cpp modules/*.h modules/*.cu extra/*.h)
add_library(detector SHARED ${sources})
target_include_directories(detector PRIVATE extra/ modules/ ${OpenCV_INCLUDE_DIRS} ${CUDA_TOOLKIT_ROOT_DIR}/include)
target_link_libraries(detector nvinfer nvinfer_plugin nvcaffe_parser "stdc++fs")


#sample
add_executable(yolo-trt samples/sample_detector.cpp)
target_include_directories(yolo-trt PRIVATE modules/ extra/)
target_link_libraries(yolo-trt detector opencv_highgui opencv_imgproc opencv_core opencv_calib3d opencv_dnn)
target_link_libraries(yolo-trt detector ${OpenCV_LIBS})



0 comments on commit 90022af

Please sign in to comment.