CMakeLists.txt 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. cmake_minimum_required(VERSION 3.5)
  2. project(gsd_var)
  3. add_definitions(-std=c++17)
  4. add_definitions(-DAPI_EXPORTS)
  5. option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
  6. set(CMAKE_CXX_STANDARD 17)
  7. set(CMAKE_BUILD_TYPE Debug)
  8. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
  9. find_package(CUDA REQUIRED)
  10. set(LINK_LIB_LIST "")
  11. set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
  12. #查找mysql是否安装
  13. find_package(MYSQL QUIET)
  14. if(MYSQL_FOUND AND ENABLE_MYSQL)
  15. message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开")
  16. include_directories(${MYSQL_INCLUDE_DIR})
  17. include_directories(${MYSQL_INCLUDE_DIR}/mysql)
  18. add_definitions(-DENABLE_MYSQL)
  19. list(APPEND LINK_LIB_LIST ${MYSQL_LIBRARIES})
  20. endif()
  21. link_directories(/usr/local/lib)
  22. include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/)
  23. include_directories(${PROJECT_SOURCE_DIR}/3rdparty/httplib/)
  24. include_directories(${PROJECT_SOURCE_DIR}/3rdparty/CSerialPort/)
  25. include_directories(/usr/local/include/)
  26. include_directories(${PROJECT_SOURCE_DIR}/3rdparty/)
  27. include_directories(${PROJECT_SOURCE_DIR}/include/)
  28. include_directories(${PROJECT_SOURCE_DIR}/models/)
  29. include_directories(${PROJECT_SOURCE_DIR}/modules/)
  30. include_directories(${PROJECT_SOURCE_DIR}/plugins/)
  31. # if(WIN32)
  32. # enable_language(CUDA)
  33. # endif(WIN32)
  34. include_directories(${PROJECT_SOURCE_DIR}/yolov5)
  35. # include and link dirs of cuda and tensorrt, you need adapt them if yours are different
  36. # cuda
  37. include_directories(/usr/local/cuda/include)
  38. link_directories(/usr/local/cuda/lib64)
  39. # tensorrt
  40. include_directories(/usr/include/x86_64-linux-gnu/)
  41. link_directories(/usr/lib/x86_64-linux-gnu/)
  42. link_directories(${PROJECT_SOURCE_DIR}/lib)
  43. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -g -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")
  44. # cuda_add_library(myplugins SHARED yololayer.cu)
  45. # target_link_libraries(myplugins nvinfer cudart)
  46. find_package(OpenCV)
  47. include_directories(${OpenCV_INCLUDE_DIRS})
  48. find_package(Drogon CONFIG REQUIRED)
  49. aux_source_directory(controllers CTL_SRC)
  50. aux_source_directory(filters FILTER_SRC)
  51. aux_source_directory(plugins PLUGIN_SRC)
  52. aux_source_directory(models MODEL_SRC)
  53. # aux_source_directory(modules MODULES_SRC)
  54. drogon_create_views(gsd_var${CMAKE_CURRENT_SOURCE_DIR}/views
  55. ${CMAKE_CURRENT_BINARY_DIR})
  56. # target_include_directories(${PROJECT_NAME}
  57. # PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
  58. # ${CMAKE_CURRENT_SOURCE_DIR}/models)
  59. cuda_add_executable(gsd_var main.cc ${PROJECT_SOURCE_DIR}/modules/InferTools.cpp ${PROJECT_SOURCE_DIR}/yolov5/calibrator.cpp ${PROJECT_SOURCE_DIR}/yolov5/preprocess.cu ${PROJECT_SOURCE_DIR}/yolov5/common.cpp)
  60. target_link_libraries(gsd_var nvinfer Drogon::Drogon ZLToolKit ${OpenCV_LIBS})
  61. target_link_libraries(gsd_var cudart)
  62. target_link_libraries(${PROJECT_NAME} myplugins)
  63. target_sources(gsd_var
  64. PRIVATE
  65. ${SRC_DIR}
  66. ${CTL_SRC}
  67. ${FILTER_SRC}
  68. ${PLUGIN_SRC}
  69. ${MODEL_SRC})
  70. if(UNIX)
  71. add_definitions(-O2 -pthread)
  72. endif(UNIX)