CMakeExpandImportedTargets: Do not read property on non-target (#15008)

Avoid behavior that is disallowed by CMP0045.  Check whether a target
exists before trying to read its properties.
Merge topic 'CMakeExpandImportedTargets-CMP0045' into next

49f32168 CMakeExpandImportedTargets: Do not read property on non-target (#15008)