2019-05-17 22:23:47 +08:00
|
|
|
function(ocv_create_builtin_videoio_plugin name target)
|
2019-01-14 18:33:38 +08:00
|
|
|
|
2019-03-02 16:31:56 +08:00
|
|
|
ocv_debug_message("ocv_create_builtin_videoio_plugin(${ARGV})")
|
|
|
|
|
2019-01-14 18:33:38 +08:00
|
|
|
if(NOT TARGET ${target})
|
|
|
|
message(FATAL_ERROR "${target} does not exist!")
|
|
|
|
endif()
|
|
|
|
if(NOT OpenCV_SOURCE_DIR)
|
|
|
|
message(FATAL_ERROR "OpenCV_SOURCE_DIR must be set to build the plugin!")
|
|
|
|
endif()
|
|
|
|
|
2019-03-02 16:31:56 +08:00
|
|
|
message(STATUS "Video I/O: add builtin plugin '${name}'")
|
|
|
|
|
2019-05-17 22:23:47 +08:00
|
|
|
foreach(src ${ARGN})
|
|
|
|
list(APPEND sources "${CMAKE_CURRENT_LIST_DIR}/src/${src}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
add_library(${name} MODULE ${sources})
|
2019-01-14 18:33:38 +08:00
|
|
|
target_include_directories(${name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
target_compile_definitions(${name} PRIVATE BUILD_PLUGIN)
|
|
|
|
target_link_libraries(${name} PRIVATE ${target})
|
|
|
|
|
|
|
|
foreach(mod opencv_videoio opencv_core opencv_imgproc opencv_imgcodecs)
|
2019-06-10 19:13:54 +08:00
|
|
|
ocv_target_link_libraries(${name} LINK_PRIVATE ${mod})
|
|
|
|
ocv_target_include_directories(${name} PRIVATE "${OPENCV_MODULE_${mod}_LOCATION}/include")
|
2019-01-14 18:33:38 +08:00
|
|
|
endforeach()
|
|
|
|
|
2019-05-31 21:18:00 +08:00
|
|
|
if(WIN32)
|
|
|
|
set(OPENCV_PLUGIN_VERSION "${OPENCV_DLLVERSION}" CACHE STRING "")
|
|
|
|
if(CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
|
|
|
|
set(OPENCV_PLUGIN_ARCH "_64" CACHE STRING "")
|
|
|
|
else()
|
|
|
|
set(OPENCV_PLUGIN_ARCH "" CACHE STRING "")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(OPENCV_PLUGIN_VERSION "" CACHE STRING "")
|
|
|
|
set(OPENCV_PLUGIN_ARCH "" CACHE STRING "")
|
|
|
|
endif()
|
|
|
|
|
2019-01-14 18:33:38 +08:00
|
|
|
set_target_properties(${name} PROPERTIES
|
|
|
|
CXX_STANDARD 11
|
|
|
|
CXX_VISIBILITY_PRESET hidden
|
2019-05-31 21:18:00 +08:00
|
|
|
OUTPUT_NAME "${name}${OPENCV_PLUGIN_VERSION}${OPENCV_PLUGIN_ARCH}"
|
2019-01-14 18:33:38 +08:00
|
|
|
)
|
2019-06-13 20:10:24 +08:00
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
install(TARGETS ${name} OPTIONAL LIBRARY DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT plugins)
|
|
|
|
else()
|
|
|
|
install(TARGETS ${name} OPTIONAL LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT plugins)
|
|
|
|
endif()
|
2019-01-14 18:33:38 +08:00
|
|
|
|
2019-03-02 16:31:56 +08:00
|
|
|
add_dependencies(opencv_videoio_plugins ${name})
|
|
|
|
|
2019-01-14 18:33:38 +08:00
|
|
|
endfunction()
|