cmake_minimum_required(VERSION 3.5)

# set(PLATFORM ASCEND)  #开启选择华为平台,注释掉选择NVIDIA平台

if(PLATFORM MATCHES "ASCEND")   #选择华为平台
    message("ASCEND PLATFORM")
    add_definitions(-DASCEND)
    add_definitions(-DENABLE_DVPP_INTERFACE)
    set(PROJECT_NAME ascend_cann_demo)
    project(${PROJECT_NAME} VERSION 1.0)
else()
    message("NVIDIA NX PLATFORM")
    set(PROJECT_NAME nvidia_cann_demo)
    project(${PROJECT_NAME} VERSION 1.0)
endif()

    
add_definitions(-std=c++11)
add_definitions(-DAPI_EXPORTS)
if(NOT PLATFORM MATCHES "ASCEND")   
    option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
endif()
set(CMAKE_CXX_STANDARD 11)
#set(CMAKE_BUILD_TYPE Debug)
#set(CMAKE_BUILD_TYPE Release)
#add_definitions("-Wall -g")


#opencv
find_package(OpenCV REQUIRED)
# message(STATUS "${OpenCV_LIBS}")
# message(STATUS "${OpenCV_INCLUDE_DIRS}")

#grpc
#find_package(gRPC CONFIG REQUIRED)
#message(STATUS "Using gRPC ${gRPC_VERSION}")

if(NOT PLATFORM MATCHES "ASCEND")
find_package(CUDA REQUIRED)
endif()

# 设置编译工具
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64) 
set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++")

# 设置项目生成目录
set(EXECUTABLE_OUTPUT_PATH  ${PROJECT_BINARY_DIR}/out)

# 添加调试信息
set(CMAKE_SKIP_BUILD_RPATH TRUE)
#set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
#set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O0 -Wfatal-errors -pthread -w -g")
#if(NOT PLATFORM MATCHES "ASCEND")
#    set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11 -O0 -Xcompiler -fPIC -g -w ${CUDA_GEN_CODE}")
#endif()

# 设置库/头文件路径
if(PLATFORM MATCHES "ASCEND")   #华为平台 设置库/头文件路径
set(ACL_PATH "/home/nvidia/Ascend/ascend-toolkit/latest/arm64-linux")
message(STATUS "ACL_PATH: ${ACL_PATH}")

set(SYS_USR_LOCAL_INCLUDE_DIR "/usr/local/include")
set(SYS_USR_LOCAL_LIB_DIR "/usr/local/lib")

set(OPENCV_INCLUDE_DIR  ${SYS_USR_LOCAL_INCLUDE_DIR}/opencv4) 
set(OPENCV_LIB_DIR  ${SYS_USR_LOCAL_LIB_DIR}) 

set(PCL_INCLUDE ${SYS_USR_LOCAL_INCLUDE_DIR}/pcl-1.7)

set(ACL_INCLUDE_PATH ${ACL_PATH}/acllib/include)
message(STATUS "ACL_INCLUDE_PATH: ${ACL_INCLUDE_PATH}")

set(ACL_LIB_PATH ${ACL_PATH}/acllib/lib64/stub)
message(STATUS "ACL_LIB_PATH: ${ACL_LIB_PATH}")

else() #NVIDIA平台 设置库/头文件路径
set(SYS_USR_INCLUDE_DIR "/usr/include")
set(SYS_USR_LIB_DIR "/usr/lib")
set(SYS_USR_LOCAL_INCLUDE_DIR "/usr/local/include")
set(SYS_USR_LOCAL_LIB_DIR "/usr/local/lib")
set(AARCH64_LINUX_INCLUDE_DIR "/usr/include/aarch64-linux-gnu")
set(AARCH64_LINUX_LIB_DIR "/usr/lib/aarch64-linux-gnu")

#opencv3.2.0的库文件在/usr/lib/aarch64-linux-gnu下 头文件路径在/usr/include/opencv2
#opencv4.5.5的库文件在/usr/local/lib下 头文件路径在/usr/local/include/opencv4
#目前使用最新版opencv4.5.5
set(OPENCV_INCLUDE_DIR  ${SYS_USR_LOCAL_INCLUDE_DIR}/opencv4) 
set(OPENCV_LIB_DIR  ${SYS_USR_LOCAL_LIB_DIR}) 

set(CUDA_DIR  "/usr/local/cuda-10.2")
set(CUDA_INCLUDE_DIR  ${CUDA_DIR}/include)
set(CUDA_LIB_DIR  ${CUDA_DIR}/lib64)

set(TENSORRT_INCLUDE_DIR  ${AARCH64_LINUX_INCLUDE_DIR})  #tensorrt的头文件在/usr/include/aarch64-linux-gnu下
set(TENSORRT_LIB_DIR  ${AARCH64_LINUX_LIB_DIR})   #tensorrt的库文件在/usr/lib/aarch64-linux-gnu下

set(DRM_INCLUDE_DIR ${SYS_USR_INCLUDE_DIR}/libdrm)  #DRM的头文件在/usr/include/libdrm下

set(TEGRA_LIB_DIR ${AARCH64_LINUX_LIB_DIR}/tegra)   #tegra库文件路径/usr/lib/aarch64-linux-gnu/tegra

set(PCL_INCLUDE ${SYS_USR_LOCAL_INCLUDE_DIR}/pcl-1.7) #pcl头文件路径
endif()

# nvidia ascend common include
include_directories(
    #ai_matrix include
    ${PROJECT_SOURCE_DIR}/ai_matrix
    ${PROJECT_SOURCE_DIR}/ai_matrix/framework
    ${PROJECT_SOURCE_DIR}/ai_matrix/myftp
    ${PROJECT_SOURCE_DIR}/ai_matrix/myhttp
    ${PROJECT_SOURCE_DIR}/ai_matrix/myJson
    ${PROJECT_SOURCE_DIR}/ai_matrix/myJson/json
    ${PROJECT_SOURCE_DIR}/ai_matrix/mylog
    ${PROJECT_SOURCE_DIR}/ai_matrix/pcl 
    ${PROJECT_SOURCE_DIR}/ai_matrix/myqueue
    ${PROJECT_SOURCE_DIR}/ai_matrix/myshell
    ${PROJECT_SOURCE_DIR}/ai_matrix/myutils

    #nvidia ascend common cann include
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/BlockingQueue
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/CBase64
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/CommandParser
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/CommonDataType
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/ConfigParser
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/ErrorCode
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/FileManager
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/Log
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/

    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common
    #common engine include
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/ControlEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/DataSourceEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/DataUploadEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/FilterEngine
    #${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/GrpcEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/MergerEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/PackageVideoEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/PixelFormatConvertEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/PushVideoEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/RtspPushVideoEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/SaveEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/SelectBestEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/SoftH264DecodeEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/TrainAnaEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/TransEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/DataDealEngine

    #common tools rtsp_server include
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_tools/common_tools/rtsp_server/3rdpart/md5
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_tools/common_tools/rtsp_server/net/
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_tools/common_tools/rtsp_server/xop/
)

if(PLATFORM MATCHES "ASCEND")   #华为平台包含头文件路径
include_directories(
    #only ascend cann include
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/DvppCommon
    # ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/DvppCommonDevice //不需要该文件中内容
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/Framework/ModelProcess
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/Framework/ModuleManager
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/PointerDeleter
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/ResourceManager
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/SingleOpProcess
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/Statistic

    #ascend engine include
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/AlterInfoEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/ChkDateStepOneEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/ChkDateStepTwoEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/ContainerEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/DataDealEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/DecodeEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/SaveEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/TrainStepOneEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/TrainStepTwoEngine

    #acl include
    ${ACL_INCLUDE_PATH}

    #third party include
    ${SYS_USR_INCLUDE_DIR}
    ${OPENCV_INCLUDE_DIR}
    ${PCL_INCLUDE}
)   
else()  #NVIDIA平台包含头文件路径
include_directories(
    #nvidia engine include
	
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/ChkDateStepOneEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/ChkDateStepTwoEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/ContainerEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/DataSourceEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/DecodeEngine
    # ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/H264EncodeEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/ImagePreprocessEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/InferenceModelEngine
    # ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/JpegDecodeEngine
    # ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/JpegEncodeEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/MoveEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/MyYaml
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/PostProcessEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/TrainStepOneEngine
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/TrainStepTwoEngine

    #nvidia_tools yolov5 include
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_tools/nvidia_tools/yolov5/include

    #third party include
    ${CUDA_INCLUDE_DIR}
    ${TENSORRT_INCLUDE_DIR}
    ${DRM_INCLUDE_DIR}
    ${OpenCV_DIR}
    ${AARCH64_LINUX_INCLUDE_DIR}
    ${SYS_USR_LOCAL_INCLUDE_DIR}
    ${PCL_INCLUDE}
)
endif()


# 设置链接库路径
if(PLATFORM MATCHES "ASCEND")   #华为平台设置链接库路径
#ascend libs path
link_directories(${ACL_LIB_PATH}
                ${SYS_USR_LOCAL_LIB_DIR}
)
else()  #NVIDIA平台设置链接库路径
#nvidia libs path
link_directories(${SYS_USR_LOCAL_LIB_DIR}
                ${AARCH64_LINUX_LIB_DIR}
                ${OPENCV_LIB_DIR}
                ${CUDA_LIB_DIR}
                ${TENSORRT_LIB_DIR}
                ${TEGRA_LIB_DIR}
                )
endif()

#源文件
#公共源文件
file(GLOB_RECURSE COMMON_SRCS_LISTS 
    #ai_matrix src
    ${PROJECT_SOURCE_DIR}/ai_matrix/framework/*.cpp 
    ${PROJECT_SOURCE_DIR}/ai_matrix/myftp/*.cpp
    ${PROJECT_SOURCE_DIR}/ai_matrix/myhttp/*.cpp
    ${PROJECT_SOURCE_DIR}/ai_matrix/myJson/*.cpp
    ${PROJECT_SOURCE_DIR}/ai_matrix/mylog/*.cpp
    #${PROJECT_SOURCE_DIR}/ai_matrix/mypcl/*.cpp   
    ${PROJECT_SOURCE_DIR}/ai_matrix/myqueue/*.cpp
    ${PROJECT_SOURCE_DIR}/ai_matrix/myshell/*.cpp
    ${PROJECT_SOURCE_DIR}/ai_matrix/myutils/*.cpp

    #common cann src
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/CommandParser/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/ConfigParser/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/ErrorCode/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/FileManager/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/Log/*.cpp

    #common engine src
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/DataSourceEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/PixelFormatConvertEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/SoftH264DecodeEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/PackageVideoEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/PushVideoEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/RtspPushVideoEngine/*.cpp

    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/ControlEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/DataUploadEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/FilterEngine/*.cpp
#    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/GrpcEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/MergerEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/SelectBestEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/TrainAnaEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/TransEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/DataDealEngine/*.cpp

    #common tools rtsp_server src
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_tools/common_tools/rtsp_server/net/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_tools/common_tools/rtsp_server/xop/*.cpp
)


if(PLATFORM MATCHES "ASCEND")   #华为平台源文件
file(GLOB_RECURSE SRCS_LISTS 
    #only cann ascend src
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/DvppCommon/*.cpp
    # ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/DvppCommonDevice/*.cpp  //不需要该文件中内容
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/Framework/ModelProcess/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/Framework/ModuleManager/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/PointerDeleter/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/ResourceManager/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/SingleOpProcess/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_base/Base/Statistic/*.cpp

    #ascend engine src
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/AlterInfoEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/ChkDateStepOneEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/ChkDateStepTwoEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/ContainerEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/DataDealEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/DecodeEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/SaveEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/TrainStepOneEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/ascend_engine/TrainStepTwoEngine/*.cpp
)
else()  #NVIDIA平台源文件
file(GLOB_RECURSE SRCS_LISTS 
    #nvidia engine src
    #nvidia engine include
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/ControlEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/DataSourceEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/DataUploadEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/FilterEngine/*.cpp
#    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/GrpcEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/MergerEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/PackageVideoEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/PixelFormatConvertEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/PushVideoEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/RtspPushVideoEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/SaveEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/SelectBestEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/SoftH264DecodeEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/TrainAnaEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/TransEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/common_engine/DataDealEngine/*.cpp

    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/ChkDateStepOneEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/ChkDateStepTwoEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/MyYaml/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/PostProcessEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/TrainStepOneEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/TrainStepTwoEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/ContainerEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/DataSourceEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/DecodeEngine/*.cpp
   # ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/H264EncodeEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/ImagePreprocessEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/InferenceModelEngine/*.cpp
  #  ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/JpegDecodeEngine/*.cpp
  #  ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/JpegEncodeEngine/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/MoveEngine/*.cpp

    ${PROJECT_SOURCE_DIR}/nvidia_ascend_engine/nvidia_engine/*.cpp
	
    #nvidia tools yolov5 src
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_tools/nvidia_tools/yolov5/src/*.cpp
    ${PROJECT_SOURCE_DIR}/nvidia_ascend_tools/nvidia_tools/yolov5/src/*.cu
)
endif()


if(PLATFORM MATCHES "ASCEND")   #华为平台链接
add_executable(${PROJECT_NAME} ${COMMON_SRCS_LISTS} ${SRCS_LISTS})

target_link_libraries(${PROJECT_NAME} ascendcl ascend_hal acl_cblas acl_dvpp_mpi acl_dvpp acl_retr acl_tdt_queue graph #acl
pthread -ldl -Wl,-z,relro,-z,now,-z,noexecstack -pie -s stdc++  #linux system 
avformat avcodec avutil  #ffmepg
${OpenCV_LIBS} #${PCL_LIBRARY_DIRS}
pcl_common pcl_io_ply pcl_keypoints pcl_registration pcl_segmentation pcl_features pcl_io pcl_octree #pcl
pcl_sample_consensus  pcl_surface pcl_filters pcl_kdtree pcl_recognition pcl_search pcl_tracking  
yaml-cpp https_sn register_so_linux jsoncpp curl boost_system boost_filesystem ssh2 #other
#gpr grpc++_alts grpc++_error_details grpc_plugin_support grpcpp_channelz grpc++_reflection grpc grpc++ grpc_unsecure grpc++_unsecure
#protoc protobuf nsl
)

else()  #NVIDIA平台链接
#cuda_add_library(myplugins SHARED ${PROJECT_SOURCE_DIR}/nvidia_ascend_tools/nvidia_tools/yolov5/src/yololayer.cu)
#target_link_libraries(myplugins nvinfer cudart)

cuda_add_executable(${PROJECT_NAME} ${COMMON_SRCS_LISTS} ${SRCS_LISTS})

target_link_libraries(${PROJECT_NAME} pthread)       #other
target_link_libraries(${PROJECT_NAME} nvinfer nvonnxparser nvcaffe_parser nvinfer_plugin)   #TensorRT
target_link_libraries(${PROJECT_NAME} cudart cuda)   #CUDA
# target_link_libraries(${PROJECT_NAME} v4l2 EGL GLESv2 X11 nvbuf_utils nvjpeg nvosd drm)    #Multimeida
#target_link_libraries(${PROJECT_NAME} myplugins)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS}  #third party librarys ${PCL_LIBRARY_DIRS} 
pcl_common pcl_io_ply pcl_keypoints pcl_registration pcl_segmentation pcl_features pcl_io pcl_octree #pcl
pcl_sample_consensus  pcl_surface pcl_filters pcl_kdtree pcl_recognition pcl_search pcl_tracking  
avformat avcodec avutil #VideoCodecV2  
yaml-cpp https_sn register_so_linux json_linux-gcc-7_libmt jsoncpp curl boost_system boost_filesystem ssh2
#gpr grpc++_alts grpc++_error_details grpc_plugin_support grpcpp_channelz grpc++_reflection grpc grpc++ grpc_unsecure grpc++_unsecure 
#protoc protobuf nsl
aws-cpp-sdk-core aws-cpp-sdk-s3
)
target_link_libraries(${PROJECT_NAME} mysqlclient)
target_link_libraries(${PROJECT_NAME} m rt atomic ssl crypto)
endif()