Check for target before adding it to the list of libraries.