Skip to content

Commit

Permalink
videoio: load debug versions of plug-ins in debug builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mshabunin committed Apr 22, 2020
1 parent 94e36d8 commit 9415560
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/videoio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
1 change: 1 addition & 0 deletions modules/videoio/cmake/plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)

Expand Down
16 changes: 16 additions & 0 deletions modules/videoio/src/backend_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -338,6 +341,19 @@ std::vector<FileSystemPath_t> 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)
Expand Down

0 comments on commit 9415560

Please sign in to comment.