123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- # 指定CMake版本
- cmake_minimum_required(VERSION 3.5)
- #使能c++11
- set(CMAKE_CXX_STANDARD 11)
- # 项目信息
- project(gsd_ds C CXX)
- # 设置为调试版本
- set(CMAKE_BUILD_TYPE Debug)
- set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
- # 设置可执行文件路径
- # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/source/bin/)
- # ---[ Options
- option(build_inference "build module inference" ON)
- option(build_Disposition "build module Disposition" ON)
- option(build_dataType "build module dataType" ON)
- option(build_HttpClient "build module HttpClient" ON)
- option(build_md5 "build module md5" ON)
- option(build_userApp "build module userApp" ON)
- option(build_recorder "build module recorder" ON)
- option(build_Cleaner "build module Cleaner" ON)
- option(build_monitor "build module monitor" ON)
- option(build_deviceState "build module deviceState" ON)
- option(build_Manager "build module Manager" ON)
- option(build_InfineFilter "build module InfineFilter" ON)
- option(build_Shell "build module Shell" ON)
- option(WITH_FFMPEG "with ffmpeg" OFF)
- option(WITH_OPENCV "with opencv" ON)
- set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
- #查找mysql是否安装
- find_package(MYSQL QUIET)
- if(MYSQL_FOUND AND ENABLE_MYSQL)
- message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开")
- include_directories(${MYSQL_INCLUDE_DIR})
- include_directories(${MYSQL_INCLUDE_DIR}/mysql)
- add_definitions(-DENABLE_MYSQL)
- list(APPEND LINK_LIB_LIST ${MYSQL_LIBRARIES})
- endif()
- list(APPEND 3RDPARTY_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS})
- list(APPEND 3RDPARTY_LIBS ${GLOG_LIBRARIES})
- ##OpenCV
- if(WITH_OPENCV)
- if(CMAKE_TOOLCHAIN_FILE)
- if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv)
- set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_features2d opencv_flann)
- if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv2/imgcodecs)
- list(APPEND OpenCV_LIBS opencv_imgcodecs)
- endif()
- if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv2/videoio)
- list(APPEND OpenCV_LIBS opencv_videoio)
- endif()
- message(STATUS "HAVE_OPENCV enabled")
- message(STATUS "opencv libraries: ${OpenCV_LIBS}")
- set(HAVE_OPENCV true)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV")
- else()
- set (HAVE_OPENCV false)
- endif()
- else()
- set(OpenCV_FIND_QUIETLY true)
- #find_package(OpenCV REQUIRED) //this will include opencv_ts which result in crash on centos
- find_package(OpenCV OPTIONAL_COMPONENTS imgcodecs)
- find_package(OpenCV OPTIONAL_COMPONENTS videoio)
- set(optional_opencv_libs ${OpenCV_LIBS})
- find_package(OpenCV REQUIRED core imgproc highgui features2d)
- if(OpenCV_FOUND)
- if(imgcodecs_FOUND)
- list(APPEND OpenCV_LIBS optional_opencv_libs)
- endif()
- message(STATUS "HAVE_OPENCV enabled")
- message(STATUS "opencv libraries: ${OpenCV_LIBS}")
- set(HAVE_OPENCV true)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV")
- else()
- set (HAVE_OPENCV false)
- endif()
- endif()
- else()
- set (HAVE_OPENCV false)
- endif()
- set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
- # -- include
- include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/inference/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/userApp/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/md5/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/TCPClient/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/dataType/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/HttpClient/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/recorder/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/Cleaner/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/monitor/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/deviceState/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/Manager/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/Shell/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/Disposition/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/InfineFilter/include/)
- include_directories(${ToolKit_Root})
- include_directories(${MediaKit_Root})
- # -- include gstreamer
- include_directories(/usr/include/gstreamer-1.0)
- include_directories(/usr/include/glib-2.0/)
- include_directories(/usr/lib/aarch64-linux-gnu/glib-2.0/include)
- include_directories(/opt/nvidia/deepstream/deepstream-5.1/sources/includes/)
- include_directories(/usr/local/cuda-10.2/include/)
- # 寻找当前目录下所有源文件
- aux_source_directory(./source/src DIR_SRCS)
- # 添加编译参数
- add_compile_options(-Wall -std=c++11 -O2 -g -DPLATFORM_TEGRA)
- link_directories(${PROJECT_SOURCE_DIR}/lib)
- link_directories(/opt/nvidia/deepstream/deepstream-5.1/lib/)
- link_directories(/usr/local/lib/)
- list(APPEND Source_LINKER_LIBS ZLToolKit dl ${3RDPARTY_LIBS} ${OpenCV_LIBS} ${FFMPEG_LIBRARIES} pthread)
- 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})
- add_subdirectory(${PROJECT_SOURCE_DIR}/modules)
- # 指定生成的目标
- add_executable(main ${DIR_SRCS})
- # 链接
- target_link_libraries(main ${ALL_LINKER_LIBS} modules)
|