Use target libraries instead of host libraries. Fixes #11243

#11243