diff --git a/modules/videoio/CMakeLists.txt b/modules/videoio/CMakeLists.txt index 721628325f66..bf82bb0eb160 100644 --- a/modules/videoio/CMakeLists.txt +++ b/modules/videoio/CMakeLists.txt @@ -31,6 +31,10 @@ file(GLOB videoio_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h" "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/legacy/*.h") +if(OPENCV_DEBUG_POSTFIX) + ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/backend_plugin.cpp" "DEBUG_POSTFIX=${OPENCV_DEBUG_POSTFIX}") +endif() + # Removing WinRT API headers by default list(REMOVE_ITEM videoio_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cap_winrt.hpp") diff --git a/modules/videoio/cmake/plugin.cmake b/modules/videoio/cmake/plugin.cmake index 55be1c0ef5e8..95490f2e342c 100644 --- a/modules/videoio/cmake/plugin.cmake +++ b/modules/videoio/cmake/plugin.cmake @@ -40,6 +40,7 @@ function(ocv_create_builtin_videoio_plugin name target) set_target_properties(${name} PROPERTIES CXX_STANDARD 11 CXX_VISIBILITY_PRESET hidden + DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" OUTPUT_NAME "${name}${OPENCV_PLUGIN_VERSION}${OPENCV_PLUGIN_ARCH}" ) diff --git a/modules/videoio/src/backend_plugin.cpp b/modules/videoio/src/backend_plugin.cpp index f73a9ad7ac23..d8b7c3014e06 100644 --- a/modules/videoio/src/backend_plugin.cpp +++ b/modules/videoio/src/backend_plugin.cpp @@ -123,6 +123,9 @@ std::string librarySuffix() CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION) #if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__) "_64" + #endif + #if defined(_DEBUG) && defined(DEBUG_POSTFIX) + CVAUX_STR(DEBUG_POSTFIX) #endif ".dll"; return suffix; @@ -338,6 +341,19 @@ std::vector getPluginCandidates(const std::string& baseName) results.push_back(path + L"\\" + moduleName); } results.push_back(moduleName); +#if defined(_DEBUG) && defined(DEBUG_POSTFIX) + if (baseName_u == "FFMPEG") // backward compatibility + { + const FileSystemPath_t templ = toFileSystemPath(CVAUX_STR(DEBUG_POSTFIX) ".dll"); + FileSystemPath_t nonDebugName(moduleName); + size_t suf = nonDebugName.rfind(templ); + if (suf != FileSystemPath_t::npos) + { + nonDebugName.replace(suf, suf + templ.size(), L".dll"); + results.push_back(nonDebugName); + } + } +#endif // _DEBUG && DEBUG_POSTFIX #else CV_LOG_INFO(NULL, "VideoIO pluigin (" << baseName << "): glob is '" << plugin_expr << "', " << paths.size() << " location(s)"); for (const string & path : paths)