CMakeLists.txt 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. # 指定CMake版本
  2. cmake_minimum_required(VERSION 3.5)
  3. #使能c++11
  4. set(CMAKE_CXX_STANDARD 11)
  5. # 项目信息
  6. project(gsd_ds C CXX)
  7. # 设置为调试版本
  8. set(CMAKE_BUILD_TYPE Debug)
  9. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
  10. # 设置可执行文件路径
  11. # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/source/bin/)
  12. # ---[ Options
  13. option(build_inference "build module inference" ON)
  14. option(build_Disposition "build module Disposition" ON)
  15. option(build_dataType "build module dataType" ON)
  16. option(build_HttpClient "build module HttpClient" ON)
  17. option(build_md5 "build module md5" ON)
  18. option(build_userApp "build module userApp" ON)
  19. option(build_recorder "build module recorder" ON)
  20. option(build_Cleaner "build module Cleaner" ON)
  21. option(build_monitor "build module monitor" ON)
  22. option(build_deviceState "build module deviceState" ON)
  23. option(build_Manager "build module Manager" ON)
  24. option(build_InfineFilter "build module InfineFilter" ON)
  25. option(build_Shell "build module Shell" ON)
  26. option(WITH_FFMPEG "with ffmpeg" OFF)
  27. option(WITH_OPENCV "with opencv" ON)
  28. set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
  29. #查找mysql是否安装
  30. find_package(MYSQL QUIET)
  31. if(MYSQL_FOUND AND ENABLE_MYSQL)
  32. message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开")
  33. include_directories(${MYSQL_INCLUDE_DIR})
  34. include_directories(${MYSQL_INCLUDE_DIR}/mysql)
  35. add_definitions(-DENABLE_MYSQL)
  36. list(APPEND LINK_LIB_LIST ${MYSQL_LIBRARIES})
  37. endif()
  38. list(APPEND 3RDPARTY_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS})
  39. list(APPEND 3RDPARTY_LIBS ${GLOG_LIBRARIES})
  40. ##OpenCV
  41. if(WITH_OPENCV)
  42. if(CMAKE_TOOLCHAIN_FILE)
  43. if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv)
  44. set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_features2d opencv_flann)
  45. if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv2/imgcodecs)
  46. list(APPEND OpenCV_LIBS opencv_imgcodecs)
  47. endif()
  48. if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv2/videoio)
  49. list(APPEND OpenCV_LIBS opencv_videoio)
  50. endif()
  51. message(STATUS "HAVE_OPENCV enabled")
  52. message(STATUS "opencv libraries: ${OpenCV_LIBS}")
  53. set(HAVE_OPENCV true)
  54. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV")
  55. else()
  56. set (HAVE_OPENCV false)
  57. endif()
  58. else()
  59. set(OpenCV_FIND_QUIETLY true)
  60. #find_package(OpenCV REQUIRED) //this will include opencv_ts which result in crash on centos
  61. find_package(OpenCV OPTIONAL_COMPONENTS imgcodecs)
  62. find_package(OpenCV OPTIONAL_COMPONENTS videoio)
  63. set(optional_opencv_libs ${OpenCV_LIBS})
  64. find_package(OpenCV REQUIRED core imgproc highgui features2d)
  65. if(OpenCV_FOUND)
  66. if(imgcodecs_FOUND)
  67. list(APPEND OpenCV_LIBS optional_opencv_libs)
  68. endif()
  69. message(STATUS "HAVE_OPENCV enabled")
  70. message(STATUS "opencv libraries: ${OpenCV_LIBS}")
  71. set(HAVE_OPENCV true)
  72. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV")
  73. else()
  74. set (HAVE_OPENCV false)
  75. endif()
  76. endif()
  77. else()
  78. set (HAVE_OPENCV false)
  79. endif()
  80. set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
  81. # -- include
  82. include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/)
  83. include_directories(${PROJECT_SOURCE_DIR}/modules/inference/include/)
  84. include_directories(${PROJECT_SOURCE_DIR}/modules/userApp/include/)
  85. include_directories(${PROJECT_SOURCE_DIR}/modules/md5/include/)
  86. include_directories(${PROJECT_SOURCE_DIR}/modules/TCPClient/include/)
  87. include_directories(${PROJECT_SOURCE_DIR}/modules/dataType/include/)
  88. include_directories(${PROJECT_SOURCE_DIR}/modules/HttpClient/include/)
  89. include_directories(${PROJECT_SOURCE_DIR}/modules/recorder/include/)
  90. include_directories(${PROJECT_SOURCE_DIR}/modules/Cleaner/include/)
  91. include_directories(${PROJECT_SOURCE_DIR}/modules/monitor/include/)
  92. include_directories(${PROJECT_SOURCE_DIR}/modules/deviceState/include/)
  93. include_directories(${PROJECT_SOURCE_DIR}/modules/Manager/include/)
  94. include_directories(${PROJECT_SOURCE_DIR}/modules/Shell/include/)
  95. include_directories(${PROJECT_SOURCE_DIR}/modules/Disposition/include/)
  96. include_directories(${PROJECT_SOURCE_DIR}/modules/InfineFilter/include/)
  97. include_directories(${ToolKit_Root})
  98. include_directories(${MediaKit_Root})
  99. # -- include gstreamer
  100. include_directories(/usr/include/gstreamer-1.0)
  101. include_directories(/usr/include/glib-2.0/)
  102. include_directories(/usr/lib/aarch64-linux-gnu/glib-2.0/include)
  103. include_directories(/opt/nvidia/deepstream/deepstream-5.1/sources/includes/)
  104. include_directories(/usr/local/cuda-10.2/include/)
  105. # 寻找当前目录下所有源文件
  106. aux_source_directory(./source/src DIR_SRCS)
  107. # 添加编译参数
  108. add_compile_options(-Wall -std=c++11 -O2 -g -DPLATFORM_TEGRA)
  109. link_directories(${PROJECT_SOURCE_DIR}/lib)
  110. link_directories(/opt/nvidia/deepstream/deepstream-5.1/lib/)
  111. link_directories(/usr/local/lib/)
  112. list(APPEND Source_LINKER_LIBS ZLToolKit dl ${3RDPARTY_LIBS} ${OpenCV_LIBS} ${FFMPEG_LIBRARIES} pthread)
  113. list(APPEND ALL_LINKER_LIBS gstrtspserver-1.0 gstreamer-1.0 gobject-2.0 glib-2.0 nvdsgst_meta nvds_meta nvdsgst_helper nvbufsurface m ${Source_LINKER_LIBS})
  114. add_subdirectory(${PROJECT_SOURCE_DIR}/modules)
  115. # 指定生成的目标
  116. add_executable(main ${DIR_SRCS})
  117. # 链接
  118. target_link_libraries(main ${ALL_LINKER_LIBS} modules)