Ascend框架用cmake编译项目

  • 下载opencv410源码,在本机编译
  • 如果有有关于视频操作的项目,要下载ffmpeg源码编译
    ./configure
    make -j8
    make install
  • 用到dvpp
cmake_minimum_required(VERSION 3.5)
# 设置c++标准
set(CMAKE_CXX_STANDARD 17)
project(lin_threadpool)
# 默认arm
if (CMAKE_SYSTEM_NAME MATCHES "Linux")          # for Linux
message("this is linux")
# set(path lib/linux86)
set(path lib/arm)
set(opencvVersion opencv410)#设置opencv版本
add_definitions(-DENABLE_DVPP_INTERFACE)

# 头文件
include_directories(include)
include_directories(/home/ds/Ascend/ascend-toolkit/6.0.RC1.alpha003/runtime/include)
include_directories(/home/ds/Ascend/ascend-toolkit/6.0.RC1.alpha003/runtime/include)
include_directories(/home/ds/Ascend/ascend-toolkit/6.0.RC1.alpha003/runtime/include/acl/dvpp)
include_directories(/home/ds/Ascend/ascend-toolkit/6.0.RC1.alpha003/runtime/include/acl/ops)
include_directories(/home/ds/Ascend/ascend-toolkit/6.0.RC1.alpha003/runtime/include/acl)
include_directories(/home/ds/Desktop/opencv-4.1.0/include/opencv4)
include_directories(/home/ds/Desktop/opencv-4.1.0/include/opencv4/opencv2)
include_directories(/snap/protobuf/52/include)
include_directories(/snap/protobuf/52/include/google)
include_directories(/home/ds/Desktop/wjp/acllite/include)
include_directories(/usr/local/Ascend/driver/kernel/inc/driver/)
# 库文件
link_directories(/home/ds/Ascend/ascend-toolkit/6.0.RC1.alpha003/runtime/lib64)
link_directories(/home/ds/Desktop/opencv-4.1.0/build/lib)
link_directories(/snap/protobuf/52/lib)
link_directories(/home/ds/Desktop/wjp/acllite/out)
link_directories(/usr/local/Ascend/driver/lib64)
link_directories(/usr/local/Ascend/driver/lib64/stub)
link_directories(/usr/local/lib)
aux_source_directory (src SRC_LIST)
aux_source_directory (/home/ds/Desktop/wjp/acllite/src SRC_LIST1)
add_executable (main ${SRC_LIST} ${SRC_LIST1})
# c++17
# target_link_libraries (main json_linux-gcc-7_libmt opencv_core opencv_imgcodecs opencv_highgui opencv_imgproc pthread ssl crypto stdc++fs dl)
#target_link_libraries (main drvdsmi_host swresample ascend_hal c_sec mmpa drvdsmi_host avfilter avformat avdevice avcodec avutil avutil pthread ascendcl acl_dvpp stdc++ opencv_highgui opencv_core opencv_imgproc opencv_imgcodecs opencv_calib3d opencv_features2d opencv_videoio)
target_link_libraries (main  acl_dvpp ascendcl opencv_highgui opencv_imgproc opencv_core opencv_imgcodecs)

# 注意测试
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/arm)

elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")    # for Windows
message("this is windows")
add_compile_options("$<$:/utf-8>")   #解决编码问题
add_compile_options("$<$:/utf-8>") #解决编码问题
set(path lib/windows)
include_directories(include)
include_directories(${path}/hsp/include)
include_directories(${path}/include)
include_directories(${path}/opencv4.1.0/build/include)
include_directories(${path}/opencv4.1.0/build/include/opencv2)
link_directories(${path}/lib)
link_directories(${path}/hsp/lib)
link_directories(${path}/opencv4.1.0/build/x64/vc15/lib)
aux_source_directory (src SRC_LIST)
add_executable (HandVIM ${SRC_LIST})
target_link_libraries (HandVIM json_vc71_libmt opencv_world410 libhasp_windows_x64_34282)
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/win)
endif()
  • 不用dvpp
cmake_minimum_required(VERSION 3.5)
# 设置c++标准
set(CMAKE_CXX_STANDARD 17)
project(lin_threadpool)
# 默认arm
if (CMAKE_SYSTEM_NAME MATCHES "Linux")          # for Linux
message("this is linux")
# set(path lib/linux86)
set(path lib/arm)
set(opencvVersion opencv410)#设置opencv版本
# 头文件
include_directories(include)
include_directories(/home/ds/Ascend/ascend-toolkit/6.0.RC1.alpha003/runtime/include)
include_directories(/home/ds/Desktop/opencv-4.1.0/include/opencv2)
include_directories(/home/ds/Desktop/opencv-4.1.0/include/opencv4)
include_directories(/home/ds/Desktop/opencv-4.1.0/include/opencv4/opencv2)

# 库文件
link_directories(/home/ds/Ascend/ascend-toolkit/6.0.RC1.alpha003/runtime/lib64)
link_directories(/home/ds/Desktop/opencv-4.1.0/build/lib)
aux_source_directory (src SRC_LIST)
add_executable (main ${SRC_LIST})
# c++17
# target_link_libraries (main json_linux-gcc-7_libmt opencv_core opencv_imgcodecs opencv_highgui opencv_imgproc pthread ssl crypto stdc++fs dl)
target_link_libraries (main  acl_dvpp ascendcl opencv_highgui opencv_imgproc opencv_core opencv_imgcodecs)

# 注意测试
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/arm)

elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")    # for Windows
message("this is windows")
add_compile_options("$<$:/utf-8>")   #解决编码问题
add_compile_options("$<$:/utf-8>") #解决编码问题
set(path lib/windows)
include_directories(include)
include_directories(${path}/hsp/include)
include_directories(${path}/include)
include_directories(${path}/opencv4.1.0/build/include)
include_directories(${path}/opencv4.1.0/build/include/opencv2)
link_directories(${path}/lib)
link_directories(${path}/hsp/lib)
link_directories(${path}/opencv4.1.0/build/x64/vc15/lib)
aux_source_directory (src SRC_LIST)
add_executable (HandVIM ${SRC_LIST})
target_link_libraries (HandVIM json_vc71_libmt opencv_world410 libhasp_windows_x64_34282)
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/win)
endif()

你可能感兴趣的:(ffmpeg,opencv,c++)