Added group targets for samples (opencv_samples, opencv_samples_<group>), install...
authorMaksim Shabunin <maksim.shabunin@gmail.com>
Fri, 9 Feb 2018 13:17:01 +0000 (16:17 +0300)
committerMaksim Shabunin <maksim.shabunin@gmail.com>
Mon, 12 Feb 2018 15:42:36 +0000 (18:42 +0300)
cmake/OpenCVExtraTargets.cmake
cmake/OpenCVModule.cmake
samples/CMakeLists.txt

index 8dd8a97..e766f7a 100644 (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()
index e413198..fe39786 100644 (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)
index 251cca1..e6ecdf8 100644 (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()