Merge branch 'backport-fix-read-after-free' into release
Merge branch 'ninja-avoid-double-phony' into release
cmTarget: Remove unused GetInterfaceLinkLibraries method
cmTarget: De-duplicate library list expansion

Create an ExpandLinkItems method to handle evaluation of generator
expressions in a library list and expansion of the ;-list into a vector.
Replace some duplicate copies of the implementation with calls to the
new helper.
cmComputeTargetDepends: Remove unused 'linking' argument

The AddInterfaceDepends method is never called with a non-true value for
its 'linking' argument.  Drop it.
cmTarget: Simplify processILibs implementation

Combine the outer two if() conditions into a single one with &&.
Scope inner lookup result inside its condition.
cmComputeLinkDepends: Simplify CheckWrongConfigItem implementation

Combine the outer two if() conditions into a single one with &&.
cmTarget: Remove 'head' argument from GetTransitiveTargetClosure

The method is never called with any headTarget besides "this".
cmTarget: Rename Get{TransitiveTarget => LinkImplementation}Closure

The method computes the transitive closure of targets starting with
the current target link implementation libraries.  Clarify the name.
cmTarget: Cache GetLinkImplementationClosure results

Store them internally and return by reference to avoid duplicate
computation.
cmTarget: Remove 'head' argument from GetLinkInformation

No call sites use it anyway.

Co-Author: Stephen Kelly <steveire@gmail.com>
cmComputeLinkInformation: Remove 'head' argument

It is only ever constructed with the current target as its own 'head'.

Co-Author: Stephen Kelly <steveire@gmail.com>
cmTarget: Remove 'head' argument from GetLinkerLanguage

It is only ever called with the 'this' target as the head.

Co-Author: Stephen Kelly <steveire@gmail.com>
cmTarget: Drop 'head' argument from GetLinkClosure

It is only ever passed the 'this' target itself.
cmTarget: Remove 'head' argument from GetLinkImplementation

Many of the 'head' arguments added by commit v2.8.11~289^2~1 (Make
linking APIs aware of 'head' target, 2013-01-04) turned out not to be
needed.  The "link implementation" of a target never needs to be
computed with anything but itself as the 'head' target (except for
CMP0022 OLD behavior because then it is the link interface).

Remove the unused 'head' target paths.  Add "internal" versions of
cmTarget::GetDirectLinkLibraries and GetLinkImplementationLibraries
to support the CMP0022 OLD behavior without otherwise exposing the
'head' target option of these methods.
cmTarget: Drop 'head' target from GetImportInfo

Move generator expression evaluation for imported library lists out of
GetImportInfo and into a new GetImportLinkInterface helper.  This avoids
duplicating the computation and storage of all imported target info just
because some of it is parameterized on the 'head' target.
cmTarget: Constify GetTransitivePropertyTargets results

Populate a vector of "cmTarget const*" instead of "cmTarget*".
cmTarget: Constify GetLinkImplementationClosure results

Populate a vector of "cmTarget const*" instead of "cmTarget*".
cmTarget: Add method to lookup other targets in a target's scope

Move the main implementation of cmComputeLinkDepends::FindTargetToLink
into cmTarget.
Fix scope of transitive target name lookups

In cmTarget, cmGeneratorTarget, and cmGeneratorExpressionEvaluator, fix
target name lookups to occur in the cmMakefile context of the target
that referenced the name, not the current 'head' target.  The context
matters for imported targets because they are directory-scoped instead
of globally unique.  We already do this in cmComputeLinkDepends and
cmComputeTargetDepends.

Extend the InterfaceLibrary test with an example covering this behavior.