Move OpenCV find_package closely to benchmark_app (#8654)
This commit is contained in:
parent
2fc4856b8a
commit
ff1f73910f
@ -168,25 +168,15 @@ include(CMakeParseArguments)
|
||||
# [HEADERS <header files>]
|
||||
# [INCLUDE_DIRECTORIES <include dir>]
|
||||
# [DEPENDENCIES <dependencies>]
|
||||
# [OPENCV_DEPENDENCIES <opencv modules>]
|
||||
# [EXCLUDE_CLANG_FORMAT]
|
||||
#
|
||||
macro(ie_add_sample)
|
||||
set(options EXCLUDE_CLANG_FORMAT)
|
||||
set(oneValueArgs NAME)
|
||||
set(multiValueArgs SOURCES HEADERS DEPENDENCIES OPENCV_DEPENDENCIES INCLUDE_DIRECTORIES)
|
||||
set(multiValueArgs SOURCES HEADERS DEPENDENCIES INCLUDE_DIRECTORIES)
|
||||
cmake_parse_arguments(IE_SAMPLE "${options}" "${oneValueArgs}"
|
||||
"${multiValueArgs}" ${ARGN} )
|
||||
|
||||
# Find OpenCV components if exist
|
||||
if(IE_SAMPLE_OPENCV_DEPENDENCIES)
|
||||
find_package(OpenCV COMPONENTS ${IE_SAMPLE_OPENCV_DEPENDENCIES} QUIET)
|
||||
if(NOT OpenCV_FOUND)
|
||||
message(WARNING "OPENCV is disabled or not found, ${IE_SAMPLE_NAME} skipped")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Create named folders for the sources within the .vcproj
|
||||
# Empty name lists them directly under the .vcproj
|
||||
source_group("src" FILES ${IE_SAMPLE_SOURCES})
|
||||
@ -196,9 +186,6 @@ macro(ie_add_sample)
|
||||
|
||||
# Create executable file from sources
|
||||
add_executable(${IE_SAMPLE_NAME} ${IE_SAMPLE_SOURCES} ${IE_SAMPLE_HEADERS})
|
||||
if(IE_SAMPLE_OPENCV_DEPENDENCIES)
|
||||
target_compile_definitions(${IE_SAMPLE_NAME} PRIVATE USE_OPENCV)
|
||||
endif()
|
||||
|
||||
set(folder_name cpp_samples)
|
||||
if(IE_SAMPLE_NAME MATCHES ".*_c$")
|
||||
@ -221,8 +208,7 @@ macro(ie_add_sample)
|
||||
endif()
|
||||
target_include_directories(${IE_SAMPLE_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../common")
|
||||
|
||||
target_link_libraries(${IE_SAMPLE_NAME} PRIVATE ${OpenCV_LIBRARIES} ${ov_link_libraries}
|
||||
${IE_SAMPLE_DEPENDENCIES})
|
||||
target_link_libraries(${IE_SAMPLE_NAME} PRIVATE ${ov_link_libraries} ${IE_SAMPLE_DEPENDENCIES})
|
||||
if(NOT c_sample)
|
||||
target_link_libraries(${IE_SAMPLE_NAME} PRIVATE gflags)
|
||||
endif()
|
||||
|
@ -4,18 +4,15 @@
|
||||
|
||||
set(TARGET_NAME "benchmark_app")
|
||||
|
||||
if(ENABLE_OPENCV)
|
||||
set(OPENCV_MODULES core)
|
||||
endif()
|
||||
|
||||
file (GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
file (GLOB HDR ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
|
||||
|
||||
ie_add_sample(NAME ${TARGET_NAME}
|
||||
SOURCES ${SRC}
|
||||
HEADERS ${HDR}
|
||||
DEPENDENCIES format_reader ie_samples_utils
|
||||
OPENCV_DEPENDENCIES ${OPENCV_MODULES})
|
||||
DEPENDENCIES format_reader ie_samples_utils)
|
||||
|
||||
# Optional OpenCL dependnency
|
||||
|
||||
find_package(OpenCL)
|
||||
|
||||
@ -51,3 +48,13 @@ if(OpenCL_FOUND AND OpenCL_HEADERS)
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${OpenCL_HEADERS})
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE HAVE_GPU_DEVICE_MEM_SUPPORT)
|
||||
endif()
|
||||
|
||||
# Optional OpenCV dependnency
|
||||
|
||||
find_package(OpenCV COMPONENTS core QUIET)
|
||||
if(NOT OpenCV_FOUND)
|
||||
message(WARNING "OpenCV is disabled or not found, ${TARGET_NAME} will be built without OpenCV support. Set OpenCV_DIR")
|
||||
else()
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE USE_OPENCV)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE opencv_core)
|
||||
endif()
|
||||
|
@ -18,7 +18,7 @@ add_library(${TARGET_NAME} SHARED ${MAIN_SRC} ${LIBRARY_HEADERS})
|
||||
# Find OpenCV components if exist
|
||||
find_package(OpenCV COMPONENTS core imgproc imgcodecs QUIET)
|
||||
if(NOT OpenCV_FOUND)
|
||||
message(WARNING "OPENCV is disabled or not found, ${TARGET_NAME} will be built without OPENCV support")
|
||||
message(WARNING "OpenCV is disabled or not found, ${TARGET_NAME} will be built without OpenCV support")
|
||||
else()
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE ${OpenCV_LIBRARIES} ie_samples_utils)
|
||||
if(UNIX AND NOT APPLE)
|
||||
|
Loading…
Reference in New Issue
Block a user