From 02525abd9fed88c39a393285f3c78880efa09101 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 10 Sep 2023 13:11:01 +0000 Subject: [PATCH] cmake: revise OPENCV_DNN_BACKEND_DEFAULT integration - disable message on default value --- CMakeLists.txt | 2 +- modules/dnn/CMakeLists.txt | 7 ++++--- modules/dnn/src/dnn_params.cpp | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a214a1a91..40d80e112c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1672,7 +1672,7 @@ else() endif() endif() -if(BUILD_opencv_dnn) +if(BUILD_opencv_dnn AND OPENCV_DNN_BACKEND_DEFAULT) status(" Default DNN backend:" ${OPENCV_DNN_BACKEND_DEFAULT}) endif() diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt index 896ce5ded7..774e3c7b5a 100644 --- a/modules/dnn/CMakeLists.txt +++ b/modules/dnn/CMakeLists.txt @@ -227,9 +227,10 @@ if(TARGET ocv.3rdparty.openvino AND OPENCV_DNN_OPENVINO) endif() endif() -set(OPENCV_DNN_BACKEND_DEFAULT "DNN_BACKEND_OPENCV" CACHE STRING "Default backend used by the DNN module") -ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/dnn_params.cpp" "OPENCV_DNN_BACKEND_DEFAULT=${OPENCV_DNN_BACKEND_DEFAULT}") - +set(OPENCV_DNN_BACKEND_DEFAULT "" CACHE STRING "Default backend used by the DNN module (DNN_BACKEND_OPENCV if empty)") +if(OPENCV_DNN_BACKEND_DEFAULT) + ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/dnn_params.cpp" "OPENCV_DNN_BACKEND_DEFAULT=${OPENCV_DNN_BACKEND_DEFAULT}") +endif() ocv_install_used_external_targets(${libs} ${dnn_runtime_libs}) diff --git a/modules/dnn/src/dnn_params.cpp b/modules/dnn/src/dnn_params.cpp index 19d453012c..a76f4cd512 100644 --- a/modules/dnn/src/dnn_params.cpp +++ b/modules/dnn/src/dnn_params.cpp @@ -36,7 +36,11 @@ bool getParam_DNN_OPENCL_ALLOW_ALL_DEVICES() int getParam_DNN_BACKEND_DEFAULT() { static int PARAM_DNN_BACKEND_DEFAULT = (int)utils::getConfigurationParameterSizeT("OPENCV_DNN_BACKEND_DEFAULT", +#ifdef OPENCV_DNN_BACKEND_DEFAULT (size_t)OPENCV_DNN_BACKEND_DEFAULT +#else + (size_t)DNN_BACKEND_OPENCV +#endif ); return PARAM_DNN_BACKEND_DEFAULT; }