Skip to content

Commit 2d1350a

Browse files
committed
Added group targets for samples (opencv_samples, opencv_samples_<group>), install samples/data inseparate component 'samples_data'
1 parent 2200e13 commit 2d1350a

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

cmake/OpenCVExtraTargets.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@ if(BUILD_DOCS)
4343
add_custom_target(install_docs DEPENDS opencv_docs
4444
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=docs -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
4545
endif()
46+
47+
# Samples
48+
if(BUILD_EXAMPLES)
49+
add_custom_target(opencv_samples)
50+
if(ENABLE_SOLUTION_FOLDERS)
51+
set_target_properties(opencv_samples PROPERTIES FOLDER "extra")
52+
endif()
53+
endif()

cmake/OpenCVModule.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,13 @@ function(ocv_add_samples)
12511251
set_target_properties(${the_target} PROPERTIES
12521252
FOLDER "samples/${module_id}")
12531253
endif()
1254+
# Add single target to build all samples for the module: 'make opencv_samples_bioinspired'
1255+
set(parent_target opencv_samples_${module_id})
1256+
if(NOT TARGET ${parent_target})
1257+
add_custom_target(${parent_target})
1258+
add_dependencies(opencv_samples ${parent_target})
1259+
endif()
1260+
add_dependencies(${parent_target} ${the_target})
12541261

12551262
if(WIN32)
12561263
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${module_id}" COMPONENT samples)

samples/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ function(ocv_define_sample out_target source sub)
1515
if(WIN32)
1616
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${sub}" COMPONENT samples)
1717
endif()
18+
# Add single target to build all samples in the group: 'make opencv_samples_cpp'
19+
set(parent_target opencv_samples_${sub})
20+
if(NOT TARGET ${parent_target})
21+
add_custom_target(${parent_target})
22+
if(TARGET opencv_samples)
23+
add_dependencies(opencv_samples ${parent_target})
24+
endif()
25+
endif()
26+
add_dependencies(${parent_target} ${the_target})
1827
set(${out_target} ${the_target} PARENT_SCOPE)
1928
endfunction()
2029

@@ -63,7 +72,7 @@ ocv_install_example_src("." CMakeLists.txt)
6372
if(INSTALL_C_EXAMPLES)
6473
install(DIRECTORY data
6574
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/data"
66-
COMPONENT samples)
75+
COMPONENT samples_data)
6776
endif()
6877

6978
else()

0 commit comments

Comments
 (0)