1 Star 0 Fork 1

equalman/yolov5-ov2021

forked from sandman/yolov5-ov2021 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CMakeLists.txt 5.46 KB
一键复制 编辑 原始数据 按行查看 历史
sandman 提交于 2021-09-22 12:10 . initial version
cmake_minimum_required(VERSION 2.6)
set (TARGET_NAME "yolov5-ov2021")
set( EXTRA_FILES src/kernels/vector_add_kernel.cl )
project(yolov5-ov2021)
if(IE_MAIN_SOURCE_DIR)
# in case if samples are built from IE repo
set(IE_MAIN_SAMPLES_DIR ${OpenVINO_MAIN_SOURCE_DIR})
# hint for find_package(InferenceEngine in the samples folder)
set(InferenceEngine_DIR "${CMAKE_BINARY_DIR}")
else()
# in case if samples are built out of IE repo
set(IE_MAIN_SAMPLES_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
if(IE_NOT_FOUND_MESSAGE)
# the flag is used to throw a custom message in case if the IE package is not found.
find_package(InferenceEngine 2.1 QUIET)
if (NOT(InferenceEngine_FOUND))
message(FATAL_ERROR ${IE_NOT_FOUND_MESSAGE})
endif()
else()
find_package(InferenceEngine 2.1 REQUIRED)
endif()
# Find OpenCV components if exist
# find_package(OpenCV COMPONENTS highgui dnn QUIET)
find_package(OpenCV QUIET)
if(NOT(OpenCV_FOUND))
message(WARNING "OPENCV is disabled or not found, " ${TARGET_NAME} " skipped")
return()
endif()
set( FFMPEG_INCLUDES "C:/temp/ffmpeg-4.3.1-2020-11-08-full_build-shared/include" )
set( FFMPEG_LIBRARY_PATHS "C:/temp/ffmpeg-4.3.1-2020-11-08-full_build-shared/lib" )
set( FFMPEG_LIBRARYS ${FFMPEG_LIBRARY_PATHS}/avcodec.lib ${FFMPEG_LIBRARY_PATHS}/avformat.lib ${FFMPEG_LIBRARY_PATHS}/avfilter.lib ${FFMPEG_LIBRARY_PATHS}/avutil.lib ${FFMPEG_LIBRARY_PATHS}/swscale.lib)
#message(STATUS "FFMPEG_LIB_PATH: ${FFMPEG_LIBRARYS_PATHS}")
#find_library( FFMPEG_LIBS
#NAMES avcodec avformat avutil swscale
# PATHS
# ${FFMPEG_LIBRARYS_PATHS}
#)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
# Determine machine bitness
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITNESS 64)
else()
set(BITNESS 32)
endif()
# Find OpenCL include directories
find_path( OPENCL_INCLUDES
NAMES CL/cl.h OpenCL/cl.h
HINTS
$ENV{AMDAPPSDKROOT}/include
$ENV{INTELOCLSDKROOT}/include
$ENV{CUDA_PATH}/include
$ENV{OPENCL_ROOT}/include
PATHS
/usr/include
/usr/local/include
)
# Find OpenCL libraries
if(BITNESS EQUAL 64)
find_library( OPENCL_LIBS
NAMES OpenCL
HINTS
$ENV{AMDAPPSDKROOT}/lib
$ENV{INTELOCLSDKROOT}/lib
$ENV{CUDA_PATH}/lib
$ENV{OPENCL_ROOT}/lib
PATH_SUFFIXES x86_64 x64
PATHS
/usr/lib64
/usr/lib
/usr/local/lib
)
elseif(BITNESS EQUAL 32)
find_library( OPENCL_LIBS
NAMES OpenCL
HINTS
$ENV{AMDAPPSDKROOT}/lib
$ENV{INTELOCLSDKROOT}/lib
$ENV{CUDA_PATH}/lib
$ENV{OPENCL_ROOT}/lib
PATH_SUFFIXES x86 Win32
PATHS
/usr/lib32
/usr/lib
/usr/local/lib
)
endif()
if( (NOT OPENCL_INCLUDES) OR (NOT OPENCL_LIBS) )
message( FATAL_ERROR "Could not find OpenCL include/libs. Set OPENCL_ROOT to your OpenCL SDK. Download AMD APP SDK "
"http://developer.amd.com/tools-and-sdks/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/ for x86/x64 "
"or pocl http://pocl.sourceforge.net/ for ARM systems" )
else()
message(STATUS "Selected OpenCL includes from ${OPENCL_INCLUDES}")
message(STATUS "Selected OpenCL lib ${OPENCL_LIBS}")
endif()
if(CMAKE_CXX_COMPILER MATCHES ".*clang")
set(CMAKE_COMPILER_IS_CLANGXX 1)
endif()
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if(GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7 OR CMAKE_COMPILER_IS_CLANGXX)
add_definitions("-std=gnu++11")
elseif(GCC_VERSION VERSION_GREATER 4.3 OR GCC_VERSION VERSION_EQUAL 4.3)
add_definitions("-std=gnu++0x")
else()
message(FATAL_ERROR "C++11 needed. Therefore a gcc compiler with a version higher than 4.3 is needed.")
endif()
add_definitions("-fPIC -Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter -Wno-ignored-attributes")
endif()
# override cl.hp from deps. Its buggy or not present in come systems
include_directories("deps/OpenCL-CLHPP/include/")
include_directories(${OPENCL_INCLUDES} "include" "src/kernels")
# directory of opencv headers
include_directories(${OpenCV_INCLUDE_DIRS} ${FFMPEG_INCLUDES} ${IE_INCLUDE_DIR})
set(SOURCE_FILES
src/main.cpp
)
# directory of opencv library
link_directories(${OpenCV_LIBRARY_DIRS} ${FFMPEG_LIBRARY_PATHS})
add_executable(${TARGET_NAME} ${SOURCE_FILES} ${EXTRA_FILES})
target_link_libraries(${TARGET_NAME} ${OPENCL_LIBS} ${OpenCV_LIBRARIES} ${FFMPEG_LIBRARYS} ${InferenceEngine_LIBRARIES})
#set_target_properties(${TARGET_NAME} PROPERTIES
# #VS_DEBUGGER_COMMAND "debug_command"
# VS_DEBUGGER_COMMAND_ARGUMENTS "0.mp4 1.mp4 w=3840:h=2160")
#SET(CMAKE_DEFAULT_STARTUP_PROJECT ${TARGET_NAME})
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TARGET_NAME})
# Copy extra files to binary directory
foreach( extra_file ${EXTRA_FILES} )
add_custom_command(
TARGET ${TARGET_NAME} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
# ${CMAKE_CURRENT_SOURCE_DIR}/${extra_file} $(OutputPath)
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/${extra_file} ${PROJECT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/${extra_file} $<TARGET_FILE_DIR:${TARGET_NAME}>
)
endforeach( extra_file )
# message("ISPC_FLAGS 111 = ${IMPORTED_LOCATION_RELEASE}")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/equalman/yolov5-ov2021.git
git@gitee.com:equalman/yolov5-ov2021.git
equalman
yolov5-ov2021
yolov5-ov2021
master

搜索帮助