update handling of library deduplication to support build configuration keywords in the whole process (fix #565)

@tfoote @wjwwood Please review.

@wjwwood Can you please run a build with a big workspace on OS X with this branch? (I ran a successful build of (most of) desktop_full and looked at some generated CMake config files and they looked good.)