Group sources for each target and link the common libraries from a variable