Skip to content

Commit 5d369af

Browse files
committed
Merge pull request opencv#9893 from mshabunin:add-modules-whitelist
2 parents 49a5280 + 5b17410 commit 5d369af

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

cmake/OpenCVModule.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,41 @@ function(__ocv_resolve_dependencies)
416416
set(HAVE_${m} ON CACHE INTERNAL "Module ${m} will be built in current configuration")
417417
endforeach()
418418

419+
# Whitelist feature
420+
if(BUILD_LIST)
421+
# Prepare the list
422+
string(REGEX REPLACE "[ ,:]+" ";" whitelist "${BUILD_LIST}" )
423+
if(BUILD_opencv_world)
424+
list(APPEND whitelist world)
425+
endif()
426+
ocv_list_add_prefix(whitelist "opencv_")
427+
ocv_list_sort(whitelist)
428+
ocv_list_unique(whitelist)
429+
message(STATUS "Using whitelist: ${whitelist}")
430+
# Expand the list
431+
foreach(depth RANGE 10)
432+
set(new_whitelist ${whitelist})
433+
foreach(m ${whitelist})
434+
list(APPEND new_whitelist ${OPENCV_MODULE_${m}_REQ_DEPS})
435+
list(APPEND new_whitelist ${OPENCV_MODULE_${m}_PRIVATE_REQ_DEPS})
436+
endforeach()
437+
ocv_list_sort(new_whitelist)
438+
ocv_list_unique(new_whitelist)
439+
if("${whitelist}" STREQUAL "${new_whitelist}")
440+
break()
441+
endif()
442+
set(whitelist "${new_whitelist}")
443+
endforeach()
444+
# Disable modules not in whitelist
445+
foreach(m ${OPENCV_MODULES_BUILD})
446+
list(FIND whitelist ${m} idx)
447+
if(idx EQUAL -1)
448+
message(STATUS "Module ${m} disabled by whitelist")
449+
__ocv_module_turn_off(${m})
450+
endif()
451+
endforeach()
452+
endif()
453+
419454
# disable MODULES with unresolved dependencies
420455
set(has_changes ON)
421456
while(has_changes)

0 commit comments

Comments
 (0)