CMakeLists.txt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # 指定CMake版本
  2. cmake_minimum_required(VERSION 3.5)
  3. #使能c++11
  4. set(CMAKE_CXX_STANDARD 11)
  5. # 项目信息
  6. project(MIVA 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_inifile "build module inifile" 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_TCPClient "build module TCPClient" ON)
  20. option(build_recorder "build module recorder" ON)
  21. option(build_Cleaner "build modele Cleaner" ON)
  22. option(build_monitor "build modele monitor" ON)
  23. option(build_deviceState "build modele deviceState" ON)
  24. option(build_Manager "build modele Manager" ON)
  25. option(build_Shell "build modele 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 3RDPARTY_LIBS ${MYSQL_LIBRARIES})
  37. endif()
  38. add_subdirectory(framework)
  39. # ---[ Google-gflags
  40. if(CMAKE_TOOLCHAIN_FILE)
  41. set(GFLAGS_LIBRARIES gflags)
  42. else()
  43. include("${PROJECT_SOURCE_DIR}/cmake/FindGFlags.cmake")
  44. endif()
  45. list(APPEND 3RDPARTY_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIRS})
  46. list(APPEND 3RDPARTY_LIBS ${GFLAGS_LIBRARIES})
  47. # ---[ Google-glog
  48. if(CMAKE_TOOLCHAIN_FILE)
  49. set(GLOG_LIBRARIES glog)
  50. else()
  51. include("${PROJECT_SOURCE_DIR}/cmake/FindGlog.cmake")
  52. endif()
  53. list(APPEND 3RDPARTY_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS})
  54. list(APPEND 3RDPARTY_LIBS ${GLOG_LIBRARIES})
  55. ##OpenCV
  56. #if(WITH_OPENCV)
  57. # if(CMAKE_TOOLCHAIN_FILE)
  58. # if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv)
  59. # set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_features2d opencv_flann)
  60. # if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv2/imgcodecs)
  61. # list(APPEND OpenCV_LIBS opencv_imgcodecs)
  62. # endif()
  63. # if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv2/videoio)
  64. # list(APPEND OpenCV_LIBS opencv_videoio)
  65. # endif()
  66. # message(STATUS "HAVE_OPENCV enabled")
  67. # message(STATUS "opencv libraries: ${OpenCV_LIBS}")
  68. # set(HAVE_OPENCV true)
  69. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV")
  70. # else()
  71. # set (HAVE_OPENCV false)
  72. # endif()
  73. # else()
  74. # set(OpenCV_FIND_QUIETLY true)
  75. # #find_package(OpenCV REQUIRED) #this will include opencv_ts which result in crash on centos
  76. # find_package(OpenCV OPTIONAL_COMPONENTS imgcodecs)
  77. # find_package(OpenCV OPTIONAL_COMPONENTS videoio)
  78. # set(optional_opencv_libs ${OpenCV_LIBS})
  79. # find_package(OpenCV REQUIRED core imgproc highgui features2d)
  80. # if(OpenCV_FOUND)
  81. # if(imgcodecs_FOUND)
  82. # list(APPEND OpenCV_LIBS optional_opencv_libs)
  83. # endif()
  84. # message(STATUS "HAVE_OPENCV enabled")
  85. # message(STATUS "opencv libraries: ${OpenCV_LIBS}")
  86. # set(HAVE_OPENCV true)
  87. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV")
  88. # else()
  89. # set (HAVE_OPENCV false)
  90. # endif()
  91. # endif()
  92. #else()
  93. # set (HAVE_OPENCV false)
  94. #endif()
  95. set(ENV{OpenCV_DIR} "/usr/local")
  96. find_package(OpenCV REQUIRED)
  97. include_directories(include ${OpenCV_INCLUDE_DIRS})
  98. # -- include
  99. include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/)
  100. include_directories(${PROJECT_SOURCE_DIR}/modules/inference/include/)
  101. include_directories(${PROJECT_SOURCE_DIR}/modules/decoder/include/)
  102. include_directories(${PROJECT_SOURCE_DIR}/modules/userApp/include/)
  103. include_directories(${PROJECT_SOURCE_DIR}/modules/md5/include/)
  104. include_directories(${PROJECT_SOURCE_DIR}/modules/inifile/include/)
  105. include_directories(${PROJECT_SOURCE_DIR}/modules/TCPClient/include/)
  106. include_directories(${PROJECT_SOURCE_DIR}/modules/dataType/include/)
  107. include_directories(${PROJECT_SOURCE_DIR}/modules/HttpClient/include/)
  108. include_directories(${PROJECT_SOURCE_DIR}/modules/recorder/include/)
  109. include_directories(${PROJECT_SOURCE_DIR}/modules/Cleaner/include/)
  110. include_directories(${PROJECT_SOURCE_DIR}/modules/monitor/include/)
  111. include_directories(${PROJECT_SOURCE_DIR}/modules/deviceState/include/)
  112. include_directories(${PROJECT_SOURCE_DIR}/modules/Manager/include/)
  113. include_directories(${PROJECT_SOURCE_DIR}/modules/Shell/include/)
  114. include_directories(${PROJECT_SOURCE_DIR}/framework/request/include/)
  115. # -- include gstreamer
  116. include_directories(/usr/include/gstreamer-1.0)
  117. include_directories(/usr/include/glib-2.0/)
  118. include_directories(/usr/lib/aarch64-linux-gnu/glib-2.0/include)
  119. include_directories(/opt/nvidia/deepstream/deepstream/sources/includes/)
  120. include_directories(/usr/local/cuda-10.2/include/)
  121. # 寻找当前目录下所有源文件
  122. aux_source_directory(./source/src DIR_SRCS)
  123. # 添加编译参数
  124. add_compile_options(-Wall -std=c++11 -O2 -g -DPLATFORM_TEGRA)
  125. link_directories(${PROJECT_SOURCE_DIR}/lib)
  126. link_directories(/opt/nvidia/deepstream/deepstream/lib/)
  127. list(APPEND Source_LINKER_LIBS ZLToolKit dl ${3RDPARTY_LIBS} ${OpenCV_LIBS} ${FFMPEG_LIBRARIES} pthread miva_core)
  128. list(APPEND ALL_LINKER_LIBS gstreamer-1.0 gobject-2.0 glib-2.0 nvdsgst_meta nvds_meta nvdsgst_helper nvbufsurface m ${Source_LINKER_LIBS})
  129. add_subdirectory(${PROJECT_SOURCE_DIR}/modules)
  130. # 指定生成的目标
  131. add_executable(main ${DIR_SRCS})
  132. # 链接
  133. target_link_libraries(main ${ALL_LINKER_LIBS} modules)