Fix some typos in the static libs selection code
Set path hints for libraries based on includes

So that CMake won't match incompatible versions if multiple versions
of a library are installed in different prefixes.