Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move OpenCV find_package closely to benchmark_app #8654

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions inference-engine/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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$")
Expand All @@ -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()
Expand Down
19 changes: 13 additions & 6 deletions inference-engine/samples/benchmark_app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down