Currently ml and flann are mandatory dependencies, but they are required only by an example.
Add them as dependencies only if building examples.
Currently text (OCR) module is an optional dependency. However, it's required by an example and that example will fail to build if this module is not selected in the build. So it should be a dependency only when building examples, and a mandatory one when doing so.
Only bioinspired samples use highgui. However, marking it as an optional dependency is not correct, because optional should be used only if module can build even if dependency is not included in the build. For bioinspired samples, highgui is actually a mandatory dep because it doesn't build if highgui is not included.
There's no need to make it a mandatory dependency either since highgui is included anyway as automatic dependency when building examples, and if highgui is not included in build, samples are not built.
Only samples use highgui. However, marking it as an optional dependency is not correct, because optional should be used only if module can build even if dependency is not included in the build. For dpm samples, highgui is actually a mandatory dep because it doesn't build if highgui is not included.
There's no need to make it a mandatory dependency either since highgui is included anyway as automatic dependency when building examples, and if highgui is not included in build, samples are not built.