Added BUILD_LIST feature
authorMaksim Shabunin <maksim.shabunin@gmail.com>
Thu, 19 Oct 2017 14:37:36 +0000 (17:37 +0300)
committerMaksim Shabunin <maksim.shabunin@gmail.com>
Thu, 23 Nov 2017 13:06:21 +0000 (16:06 +0300)
cmake/OpenCVModule.cmake

index caa1a1e..5ce2ed6 100644 (file)
@@ -421,6 +421,41 @@ function(__ocv_resolve_dependencies)
     set(HAVE_${m} ON CACHE INTERNAL "Module ${m} will be built in current configuration")
   endforeach()
 
+  # Whitelist feature
+  if(BUILD_LIST)
+    # Prepare the list
+    string(REGEX REPLACE "[ ,:]+" ";" whitelist "${BUILD_LIST}" )
+    if(BUILD_opencv_world)
+      list(APPEND whitelist world)
+    endif()
+    ocv_list_add_prefix(whitelist "opencv_")
+    ocv_list_sort(whitelist)
+    ocv_list_unique(whitelist)
+    message(STATUS "Using whitelist: ${whitelist}")
+    # Expand the list
+    foreach(depth RANGE 10)
+      set(new_whitelist ${whitelist})
+      foreach(m ${whitelist})
+        list(APPEND new_whitelist ${OPENCV_MODULE_${m}_REQ_DEPS})
+        list(APPEND new_whitelist ${OPENCV_MODULE_${m}_PRIVATE_REQ_DEPS})
+      endforeach()
+      ocv_list_sort(new_whitelist)
+      ocv_list_unique(new_whitelist)
+      if("${whitelist}" STREQUAL "${new_whitelist}")
+        break()
+      endif()
+      set(whitelist "${new_whitelist}")
+    endforeach()
+    # Disable modules not in whitelist
+    foreach(m ${OPENCV_MODULES_BUILD})
+      list(FIND whitelist ${m} idx)
+      if(idx EQUAL -1)
+        message(STATUS "Module ${m} disabled by whitelist")
+        __ocv_module_turn_off(${m})
+      endif()
+    endforeach()
+  endif()
+
   # disable MODULES with unresolved dependencies
   set(has_changes ON)
   while(has_changes)