Revert "Refactor find_library code"

This reverts commit abb2503c586ab1061a0a2eeeda34e227b67006c5.