123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- # 指定CMake版本
- cmake_minimum_required(VERSION 3.5)
- #使能c++11
- set(CMAKE_CXX_STANDARD 11)
- # 项目信息
- project(MIVA 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_inifile "build module inifile" 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_TCPClient "build module TCPClient" ON)
- option(build_recorder "build module recorder" ON)
- option(build_Cleaner "build modele Cleaner" ON)
- option(build_monitor "build modele monitor" ON)
- option(build_deviceState "build modele deviceState" ON)
- option(build_Manager "build modele Manager" ON)
- option(build_Shell "build modele 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 3RDPARTY_LIBS ${MYSQL_LIBRARIES})
- endif()
- add_subdirectory(framework)
- # ---[ Google-gflags
- if(CMAKE_TOOLCHAIN_FILE)
- set(GFLAGS_LIBRARIES gflags)
- else()
- include("${PROJECT_SOURCE_DIR}/cmake/FindGFlags.cmake")
- endif()
- list(APPEND 3RDPARTY_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIRS})
- list(APPEND 3RDPARTY_LIBS ${GFLAGS_LIBRARIES})
- # ---[ Google-glog
- if(CMAKE_TOOLCHAIN_FILE)
- set(GLOG_LIBRARIES glog)
- else()
- include("${PROJECT_SOURCE_DIR}/cmake/FindGlog.cmake")
- 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(ENV{OpenCV_DIR} "/usr/local")
- find_package(OpenCV REQUIRED)
- include_directories(include ${OpenCV_INCLUDE_DIRS})
- # -- include
- include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/inference/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/decoder/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/userApp/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/md5/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/inifile/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}/framework/request/include/)
- # -- 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/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/lib/)
- list(APPEND Source_LINKER_LIBS ZLToolKit dl ${3RDPARTY_LIBS} ${OpenCV_LIBS} ${FFMPEG_LIBRARIES} pthread miva_core)
- 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})
- add_subdirectory(${PROJECT_SOURCE_DIR}/modules)
- # 指定生成的目标
- add_executable(main ${DIR_SRCS})
- # 链接
- target_link_libraries(main ${ALL_LINKER_LIBS} modules)
|