opencv: move the dependency check to a single place
Previously we were checking for opencv dep in 2 different places, and the checks would vary in terms of how complex and exhaustive they were.
Move the check into the libs module and reuse the result later on.
This MR is based on top of !1438 (merged) to avoid conflicts once said MR is merged.