Added group targets for samples (opencv_samples, opencv_samples_<group>), install samples/data inseparate component 'samples_data'

This commit is contained in:
Maksim Shabunin 2018-02-09 16:17:01 +03:00
parent 2200e13c71
commit 2d1350a9d6
3 changed files with 25 additions and 1 deletions

View File

@ -43,3 +43,11 @@ if(BUILD_DOCS)
add_custom_target(install_docs DEPENDS opencv_docs
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=docs -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif()
# Samples
if(BUILD_EXAMPLES)
add_custom_target(opencv_samples)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(opencv_samples PROPERTIES FOLDER "extra")
endif()
endif()

View File

@ -1251,6 +1251,13 @@ function(ocv_add_samples)
set_target_properties(${the_target} PROPERTIES
FOLDER "samples/${module_id}")
endif()
# Add single target to build all samples for the module: 'make opencv_samples_bioinspired'
set(parent_target opencv_samples_${module_id})
if(NOT TARGET ${parent_target})
add_custom_target(${parent_target})
add_dependencies(opencv_samples ${parent_target})
endif()
add_dependencies(${parent_target} ${the_target})
if(WIN32)
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${module_id}" COMPONENT samples)

View File

@ -15,6 +15,15 @@ function(ocv_define_sample out_target source sub)
if(WIN32)
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${sub}" COMPONENT samples)
endif()
# Add single target to build all samples in the group: 'make opencv_samples_cpp'
set(parent_target opencv_samples_${sub})
if(NOT TARGET ${parent_target})
add_custom_target(${parent_target})
if(TARGET opencv_samples)
add_dependencies(opencv_samples ${parent_target})
endif()
endif()
add_dependencies(${parent_target} ${the_target})
set(${out_target} ${the_target} PARENT_SCOPE)
endfunction()
@ -63,7 +72,7 @@ ocv_install_example_src("." CMakeLists.txt)
if(INSTALL_C_EXAMPLES)
install(DIRECTORY data
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/data"
COMPONENT samples)
COMPONENT samples_data)
endif()
else()