Merge pull request #24252 from opencv-pushbot:gitee/alalek/refactor_24218

cmake: revise OPENCV_DNN_BACKEND_DEFAULT integration
This commit is contained in:
Alexander Smorkalov 2023-09-11 08:55:19 +03:00 committed by GitHub
commit 62c0556c58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -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()

View File

@ -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})

View File

@ -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;
}