From 75b48e9cdcc809cfcc150acf63ee36c26a771558 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 17 Aug 2023 16:45:01 +0400 Subject: [PATCH] Added OpenCV minimal versions (#19231) --- cmake/extra_modules.cmake | 6 ++++++ docs/snippets/CMakeLists.txt | 2 +- samples/c/common/opencv_c_wrapper/CMakeLists.txt | 4 ++-- samples/cpp/benchmark_app/CMakeLists.txt | 4 ++-- samples/cpp/common/format_reader/CMakeLists.txt | 4 ++-- src/common/preprocessing/tests/CMakeLists.txt | 4 ++-- src/core/template_extension/old/CMakeLists.txt | 5 ++++- src/plugins/template/tests/functional/CMakeLists.txt | 4 ++-- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/cmake/extra_modules.cmake b/cmake/extra_modules.cmake index c6d4a99712c..039824c34e4 100644 --- a/cmake/extra_modules.cmake +++ b/cmake/extra_modules.cmake @@ -5,6 +5,9 @@ function(ie_generate_dev_package_config) # dummy check that OpenCV is here find_package(OpenCV QUIET) + if(OpenCV_VERSION VERSION_LESS 3.0) + set(OpenCV_FOUND OFF) + endif() foreach(component IN LISTS openvino_export_components) # export all targets with prefix and use them during extra modules build @@ -37,6 +40,9 @@ endfunction() function(ov_generate_dev_package_config) # dummy check that OpenCV is here find_package(OpenCV QUIET) + if(OpenCV_VERSION VERSION_LESS 3.0) + set(OpenCV_FOUND OFF) + endif() foreach(component IN LISTS openvino_export_components) # filter out targets which are installed by OpenVINOConfig.cmake static build case diff --git a/docs/snippets/CMakeLists.txt b/docs/snippets/CMakeLists.txt index c41deb340e1..9ddc278fd57 100644 --- a/docs/snippets/CMakeLists.txt +++ b/docs/snippets/CMakeLists.txt @@ -38,7 +38,7 @@ endif() # remove OpenCV related sources find_package(OpenCV QUIET COMPONENTS core imgcodecs) -if(NOT OpenCV_FOUND) +if(NOT OpenCV_FOUND OR NOT OpenCV_VERSION VERSION_GREATER_EQUAL 3) list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/ShapeInference.cpp") endif() diff --git a/samples/c/common/opencv_c_wrapper/CMakeLists.txt b/samples/c/common/opencv_c_wrapper/CMakeLists.txt index 77b307a970a..3786a81bcc4 100644 --- a/samples/c/common/opencv_c_wrapper/CMakeLists.txt +++ b/samples/c/common/opencv_c_wrapper/CMakeLists.txt @@ -16,8 +16,8 @@ add_library(${TARGET_NAME} STATIC ${HEADERS} ${SOURCES}) # Find OpenCV components if exist find_package(OpenCV QUIET COMPONENTS core imgproc imgcodecs) -if(NOT OpenCV_FOUND) - message(WARNING "OPENCV is disabled or not found, ${TARGET_NAME} is built without OPENCV support") +if(NOT OpenCV_FOUND OR NOT OpenCV_VERSION VERSION_GREATER_EQUAL 3) + message(WARNING "OpenCV ver. 3.0+ is not found, ${TARGET_NAME} is built without OPENCV support") else() target_compile_definitions(${TARGET_NAME} PRIVATE USE_OPENCV) endif() diff --git a/samples/cpp/benchmark_app/CMakeLists.txt b/samples/cpp/benchmark_app/CMakeLists.txt index 86559d181df..1ec22b20cb0 100644 --- a/samples/cpp/benchmark_app/CMakeLists.txt +++ b/samples/cpp/benchmark_app/CMakeLists.txt @@ -153,8 +153,8 @@ endif() # Optional OpenCV dependency find_package(OpenCV QUIET COMPONENTS core) -if(NOT OpenCV_FOUND) - message(WARNING "OpenCV is disabled or not found, ${TARGET_NAME} will be built without OpenCV support. Set OpenCV_DIR") +if(NOT OpenCV_FOUND OR NOT OpenCV_VERSION VERSION_GREATER_EQUAL 3) + message(WARNING "OpenCV ver. 3.0+ is 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) diff --git a/samples/cpp/common/format_reader/CMakeLists.txt b/samples/cpp/common/format_reader/CMakeLists.txt index 633c055aa02..b2af885de82 100644 --- a/samples/cpp/common/format_reader/CMakeLists.txt +++ b/samples/cpp/common/format_reader/CMakeLists.txt @@ -18,8 +18,8 @@ add_library(${TARGET_NAME} STATIC ${MAIN_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLI # Find OpenCV components if exist find_package(OpenCV QUIET COMPONENTS core imgproc imgcodecs) -if(NOT OpenCV_FOUND) - message(WARNING "OpenCV is disabled or not found, ${TARGET_NAME} will be built without OpenCV support") +if(NOT OpenCV_FOUND OR NOT OpenCV_VERSION VERSION_GREATER_EQUAL 3) + message(WARNING "OpenCV ver. 3.0+ is 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) diff --git a/src/common/preprocessing/tests/CMakeLists.txt b/src/common/preprocessing/tests/CMakeLists.txt index 0a2b69b3b59..9518b6f3e41 100644 --- a/src/common/preprocessing/tests/CMakeLists.txt +++ b/src/common/preprocessing/tests/CMakeLists.txt @@ -7,8 +7,8 @@ set(TARGET fluid_preproc_tests) ov_deprecated_no_errors() find_package(OpenCV QUIET COMPONENTS gapi core imgproc) -if(NOT OpenCV_FOUND) - message(WARNING "No suitable OpenCV version detected, ${TARGET} skipped") +if(NOT OpenCV_FOUND OR NOT OpenCV_VERSION VERSION_GREATER_EQUAL 4) + message(WARNING "OpenCV ver. 4.0+ is not found, ${TARGET} skipped") return() endif() diff --git a/src/core/template_extension/old/CMakeLists.txt b/src/core/template_extension/old/CMakeLists.txt index e5298c2435f..f43d1b75778 100644 --- a/src/core/template_extension/old/CMakeLists.txt +++ b/src/core/template_extension/old/CMakeLists.txt @@ -9,11 +9,14 @@ set(TARGET_NAME "template_extension") find_package(OpenVINO REQUIRED COMPONENTS Runtime OPTIONAL_COMPONENTS ONNX) find_package(OpenCV QUIET COMPONENTS core) +if(OpenCV_VERSION VERSION_LESS 3) + set(OpenCV_FOUND OFF) +endif() set(SRC cpu_kernel.cpp extension.cpp op.cpp) if(OpenCV_FOUND) - set(SRC ${SRC} fft_kernel.cpp fft_op.cpp) + list(APPEND SRC fft_kernel.cpp fft_op.cpp) endif() add_library(${TARGET_NAME} MODULE ${SRC}) diff --git a/src/plugins/template/tests/functional/CMakeLists.txt b/src/plugins/template/tests/functional/CMakeLists.txt index b45364d93c6..2aef6104d98 100644 --- a/src/plugins/template/tests/functional/CMakeLists.txt +++ b/src/plugins/template/tests/functional/CMakeLists.txt @@ -27,12 +27,12 @@ ov_add_test_target( find_package(OpenCV QUIET COMPONENTS core imgproc) -if(OpenCV_FOUND) +if(OpenCV_FOUND AND OpenCV_VERSION VERSION_GREATER_EQUAL 3.4) message("-- Reference preprocessing: OpenCV tests are enabled") target_compile_definitions(${TARGET_NAME} PRIVATE OPENCV_TEMPLATE_TESTS) target_link_libraries(${TARGET_NAME} PRIVATE opencv_imgproc opencv_core) else() - message("-- Reference preprocessing: OpenCV tests are disabled") + message("-- Reference preprocessing: OpenCV tests are disabled, because OpenCV ver. 3.4+ is not found") endif() if (ENABLE_INTEL_CPU)