# <add extra installation rules>
# ocv_add_accuracy_tests(<extra dependencies>)
# ocv_add_perf_tests(<extra dependencies>)
+# ocv_add_samples(<extra dependencies>)
#
#
# If module have no "extra" then you can define it in one line:
ocv_add_accuracy_tests()
ocv_add_perf_tests()
+ ocv_add_samples()
endmacro()
# ensures that all passed modules are available
endif()
endfunction()
+function(ocv_add_samples)
+ set(samples_path "${CMAKE_CURRENT_SOURCE_DIR}/samples")
+ string(REGEX REPLACE "^opencv_" "" module_id ${the_module})
+
+ if(BUILD_EXAMPLES AND EXISTS "${samples_path}")
+ set(samples_deps ${the_module} ${OPENCV_MODULE_${the_module}_DEPS} opencv_highgui ${ARGN})
+ ocv_check_dependencies(${samples_deps})
+
+ if(OCV_DEPENDENCIES_FOUND)
+ file(GLOB sample_sources "${samples_path}/*.cpp")
+ ocv_include_modules(${OPENCV_MODULE_${the_module}_DEPS})
+
+ foreach(source ${sample_sources})
+ get_filename_component(name "${source}" NAME_WE)
+ set(the_target "example_${module_id}_${name}")
+
+ add_executable(${the_target} "${source}")
+ target_link_libraries(${the_target} ${samples_deps})
+
+ set_target_properties(${the_target} PROPERTIES PROJECT_LABEL "(sample) ${name}")
+
+ if(ENABLE_SOLUTION_FOLDERS)
+ set_target_properties(${the_target} PROPERTIES
+ OUTPUT_NAME "${module_id}-example-${name}"
+ FOLDER "samples/${module_id}")
+ endif()
+
+ if(WIN32)
+ install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${module_id}" COMPONENT main)
+ endif()
+ endforeach()
+ endif()
+ endif()
+
+ if(INSTALL_C_EXAMPLES AND NOT WIN32 AND EXISTS "${samples_path}")
+ file(GLOB sample_files "${samples_path}/*")
+ install(FILES ${sample_files}
+ DESTINATION share/OpenCV/samples/${module_id}
+ PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
+ endif()
+endfunction()
+
# internal macro; finds all link dependencies of the module
# should be used at the end of CMake processing
macro(__ocv_track_module_link_dependencies the_module optkind)