mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
Added the ability to have samples inside a module.
This commit is contained in:
parent
6ebfa87181
commit
e5735282da
@ -33,6 +33,7 @@
|
|||||||
# <add extra installation rules>
|
# <add extra installation rules>
|
||||||
# ocv_add_accuracy_tests(<extra dependencies>)
|
# ocv_add_accuracy_tests(<extra dependencies>)
|
||||||
# ocv_add_perf_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:
|
# If module have no "extra" then you can define it in one line:
|
||||||
@ -578,6 +579,7 @@ macro(ocv_define_module module_name)
|
|||||||
|
|
||||||
ocv_add_accuracy_tests()
|
ocv_add_accuracy_tests()
|
||||||
ocv_add_perf_tests()
|
ocv_add_perf_tests()
|
||||||
|
ocv_add_samples()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# ensures that all passed modules are available
|
# ensures that all passed modules are available
|
||||||
@ -722,6 +724,48 @@ function(ocv_add_accuracy_tests)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
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
|
# internal macro; finds all link dependencies of the module
|
||||||
# should be used at the end of CMake processing
|
# should be used at the end of CMake processing
|
||||||
macro(__ocv_track_module_link_dependencies the_module optkind)
|
macro(__ocv_track_module_link_dependencies the_module optkind)
|
||||||
|
Loading…
Reference in New Issue
Block a user