Commit Graph

762 Commits

Author SHA1 Message Date
Brad King 4b8130b8de cmTarget: Drop 'head' argument from GetSourceFiles
No call sites need it to be anything but 'this'.
2014-07-14 09:46:53 -04:00
Brad King 4c763dd1f1 cmTarget: Drop 'head' argument from GetLanguages
No call sites need it to be anything but 'this'.
2014-07-14 09:46:53 -04:00
Brad King 190cabe7c1 cmTarget: Drop 'head' argument from ComputeLinkImplementationLanguages
No call sites need it to be anything but 'this'.
2014-07-14 09:46:53 -04:00
Brad King 5ba3cbbd24 Merge topic 'refactor-link-internals'
f45ede61 cmTarget: Fix CMP0022 OLD breakage from recent refactoring
2014-07-14 09:38:00 -04:00
Brad King affe9d56a2 Allow INTERFACE_SOURCES to specify $<TARGET_OBJECTS> (#14970)
Fix cmTarget::GetSourceFiles to set EvaluateForBuildsystem on the
$<TARGET_PROPERTY:...,INTERFACE_SOURCES> generator expression so that
the $<TARGET_OBJECTS> generator expression is allowed within an
INTERFACE_SOURCES value.

Extend the InterfaceLibrary test to cover this case.  Extend the
RunCMake.TargetObjects test to cover failure of $<TARGET_OBJECTS>
when used through $<TARGET_PROPERTY:...,INTERFACE_SOURCES> in a
non-buildsystem context.
2014-07-14 09:09:32 -04:00
Brad King f45ede61a1 cmTarget: Fix CMP0022 OLD breakage from recent refactoring
In commit 7b0834e9 (cmTarget: Refactor internal LinkImplementation map,
2014-06-19) cmTarget::GetLinkImplementationLibrariesInternal was changed
accidentally to pass "this" to ComputeLinkImplementation instead of
"head".  Change it back.
2014-07-10 16:01:04 -04:00
Brad King 93790506f5 cmTarget: Simplify INTERFACE_INCLUDE_DIRECTORIES usage requirement lookup
Use the AddInterfaceEntries helper to avoid duplication.  In
TargetPropertyEntry, replace the TargetName string member with a
reference to the full cmLinkImplItem that produced the entry.  This is
possible because the cmLinkImplItem is available in AddInterfaceEntries
(it was not available in GetIncludeDirectories).  Having the full
cmLinkImplItem allows processIncludeDirectories to implement CMP0027 OLD
behavior without repeating the target name lookup.

Update the RunCMake.CompatibleInterface test DebugProperties case
expected output for the new order of the messages.
2014-07-07 08:52:42 -04:00
Brad King b5b098ebb3 cmTarget: Simplify CMP0027 logic in processIncludeDirectories
Evaluate and lookup the target name only once per TargetPropertyEntry
instead of repeating it for each include directory entry.  Use a local
checkCMP0027 variable to record whether the policy should be checked.
Evaluate the target name as a generator expression only if it looks like
one.  Lookup the target by name only after evaluation of generator
expressions.
2014-07-07 08:52:41 -04:00
Brad King 5e07dcf7c8 cmTarget: Add to LinkImplementation whether each library was a genex
Implementation of CMP0027 OLD behavior needs to know whether each entry
in LinkImplementation::Libraries came from a generator expression or
not.  Add a FromGenex member to cmLinkImplItem to record this.
2014-07-07 08:52:41 -04:00
Brad King f77b384cf6 cmTarget: Simplify INTERFACE_COMPILE_FEATURES usage requirement lookup
Use the AddInterfaceEntries helper to avoid duplication.
2014-07-07 08:52:41 -04:00
Brad King 61ef8daad5 cmTarget: Simplify INTERFACE_COMPILE_DEFINITIONS usage requirement lookup
Use the AddInterfaceEntries helper to avoid duplication.
2014-07-07 08:52:41 -04:00
Brad King d9586f83f1 cmTarget: Simplify INTERFACE_COMPILE_OPTIONS usage requirement lookup
Use the AddInterfaceEntries helper to avoid duplication.
2014-07-07 08:52:40 -04:00
Brad King 3156275bc7 cmTarget: Simplify INTERFACE_SOURCES usage requirement lookup
Use the AddInterfaceEntries helper to avoid duplication.
2014-07-07 08:52:40 -04:00
Brad King 363cd33ebe cmTarget: Add method to add usage requirements from linked interfaces
Create a cmTargetInternals::AddInterfaceEntries method to construct a
$<TARGET_PROPERTY:tgt,INTERFACE_XYZ> generator expression and evaluate
it for every target in the link implementation.  This will be useful to
de-duplicate such evaluation for each usage requirement separately.

The new method will soon be used in the implementation of the
INTERFACE_* usage requirement lookup methods (GetSourceFiles,
GetCompileOptions, GetCompileDefinitions, GetCompileFeatures,
GetIncludeDirectories).  It is necessary for these methods to determine
whether an expression in LinkImplementationPropertyEntries evaluates to
a target or not because generator expression evaluation reports an error
for non-targets and we construct a $<TARGET_PROPERTY:tgt,INTERFACE_XYZ>
expression for each entry that is a target.

The implementation of each usage requirement currently processes the
LinkImplementationPropertyEntries and evaluates all generator
expressions to determine targets.  That is no longer necessary because
GetLinkImplementationLibraries now returns resolved and cached targets
together with their name.  Use it to implement AddInterfaceEntries.
2014-07-07 08:52:40 -04:00
Brad King 251e835b3f cmTarget: Add to LinkImplementation a backtrace for each library
Allow clients to provide backtrace context on evaluation diagnostics.
2014-07-07 08:52:40 -04:00
Brad King 848c8ccf18 cmTarget: Refactor LinkImplementation to allow more information
Create a cmLinkImplItem class derived from cmLinkItem so more
information can be added to link implementation entries than link
interface entries.  Convert the LinkImplementation Libraries member to
hold it.  Update client sites accordingly.
2014-07-07 08:52:39 -04:00
Stephen Kelly 65aa5442b7 Target: Return null when a transitive property is not defined.
Commit v2.8.11~310^2~1 (Keep track of INCLUDE_DIRECTORIES as a vector of
structs., 2012-11-19) added special case of INCLUDE_DIRECTORIES
for the purpose of origin-tracking of individual entries in the property. It
introduced a bug in that it returned an empty string instead of '0' in the
case that no includes have been set.

Commit v2.8.11~289^2~2 (Handle INTERFACE properties transitively for includes
and defines., 2012-09-23) introduced transitive handling of the property
through the link implementation, together with a whitelist of properties
which would be evaluated transitively. Because of the bug introduced
previously, the 'prop' in TargetPropertyNode is non-null,
meaning that the content (the empty string) would be evaluated as a generator
expression.  This was harmless as the follow-up code was only for 'INTERFACE_'
variants of target properties, so the effect was the same.

Commits v2.8.11~280^2~2 (Keep track of properties used to determine linker
libraries., 2012-11-05) and v2.8.11~280^2~1 (Add API to calculate
link-interface-dependent bool properties or error., 2013-01-06) added a way
to track and report errors on properties which both determine and are
determined by the link implementation.  This was later used in generator
expression evaluation by commit v2.8.11~252^2~2 (Make INTERFACE determined
properties readable in generator expressions., 2013-01-19).  If a property
is unset (null), and the link implementation of the target was not being
evaluated, this commit made it possible to evaluate the property from the
link implementation instead.  If the link implementation was being evaluated,
an empty string was returned from the generator expression evaluation, which
might be later reported as an error.

The above logic was written for 'compatible interface' properties, but in
fact it should have also included other properties.  Because of the
empty-string-instead-of-null bug, this code block is not entered for the
INCLUDE_DIRECTORIES property.  At this point, however, the bug still does
not significantly affect behavior, because the follow-up code is still a
no-op for the INCLUDE_DIRECTORIES property, and an empty string is returned
regardless. Commit v2.8.11~189^2~6 (Use the link information as a source of
compile definitions and includes., 2013-02-12) refactored the logic, but also
without a change in behavior.

Commit v2.8.11~156^2~2 (Expand includes and defines transitively
in 'external' genexes., 2013-02-13) refactored the logic again, this time with
a change of behavior. The INCLUDE_DIRECTORIES property was then mapped to
INTERFACE_INCLUDE_DIRECTORIES during transitive generator expression
evaluation.  Because the transitive evaluation involved evaluation of the
link implementation, this introduced a recursive loop and a segfault with
code like:

  add_library(empty1 ...)
  add_library(empty2 ...)
  target_link_libraries(empty1
    PRIVATE
      $<$<STREQUAL:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>,/foo/bar>:empty2>
  )

As there is no real use-case for reading a target property like that while
evaluating the link implementation, this went unnoticed.  The same pattern
was followed for other special-cased reads of transitive target properties
such as COMPILE_DEFINITIONS.

The segfault was fixed in the parent commit, but change the property to
return null when appropriate for other future uses.
2014-07-02 00:10:58 +02:00
Brad King 2463797996 cmTarget: Refactor ComputeLinkImplementation
Use LinkImplementationPropertyEntries directly instead of asking
GetProperty to construct a string for LINK_LIBRARIES.  This gives us
access to the entry backtraces.
2014-06-25 10:33:36 -04:00
Brad King 7812d2a912 cmTarget: Pre-indent a block in ComputeLinkImplementation
Prepare to move it into another block without extra whitespace changes.
2014-06-25 10:33:36 -04:00
Brad King f48d8bd6f6 cmTarget: Shorten a long line in ComputeLinkImplementation
Prepare to change its indentation without exceeding line length limit.
2014-06-25 10:33:36 -04:00
Brad King 7b0834e9bb cmTarget: Refactor internal LinkImplementation map
If ComputeLinkImplementationLanguages were ever to cause
GetLinkImplementationLibraries to be invoked then a LinkImplMap entry
may appear in the middle of computing it in GetLinkInformation.  Instead
create the map entry up front and store in it boolean values indicating
which pieces of the LinkImplementation structure have been populated.
This approach leads to shorter code that is easier to follow too.
2014-06-25 10:33:36 -04:00
Brad King b8651d970d cmTarget: Remove unnecessary 'mutable' markup
Members of the cmTargetInternals structure do not need to be made
'mutable' even to cache data because there is no reason for the
internal methods to be 'const'.
2014-06-25 10:33:36 -04:00
Brad King 0192be5181 cmTarget: De-duplicate link interface evaluation for $<LINK_ONLY>
Teach GetTransitivePropertyTargets to use the GetLinkInterfaceLibraries
method with usage_requirements_only==true instead of evaluating the
INTERFACE_LINK_LIBRARIES property directly.  This avoids duplicate
evaluations and makes use of the caching done by
GetLinkInterfaceLibraries.
2014-06-25 10:20:52 -04:00
Brad King 6ead631bf9 cmTarget: Teach GetLinkInterfaceLibraries to support $<LINK_ONLY>
Add a 'usage_requirements_only' parameter to GetLinkInterfaceLibraries
and supporting internal APIs to pass through to ExpandLinkItems so it
knows whether to use SetTransitivePropertiesOnly while evaluating
generator expressions.
2014-06-25 10:01:56 -04:00
Brad King b030a7f1ca cmTarget: De-duplicate link interface genex code for $<LINK_ONLY>
Simplify the implementation of GetTransitivePropertyTargets by using
ExpandLinkItems with usage_requirements_only==true to evaluate the
generator expressions in the link interface for us.
2014-06-25 09:32:38 -04:00
Brad King 1001490df2 cmTarget: Teach ExpandLinkItems how to support $<LINK_ONLY>
Add a 'usage_requirements_only' parameter to ExpandLinkItems so that it
knows whether to use SetTransitivePropertiesOnly while evaluating
generator expressions.  Update existing call sites to pass 'false' since
they are for linking and not usage requirements.
2014-06-25 09:32:21 -04:00
Brad King f5c18c9c1c cmTarget: Drop GetDirectLinkLibraries methods
Inline the implementation in the last remaining caller and drop the
methods.
2014-06-23 09:22:08 -04:00
Brad King 281eb3d8a6 cmTarget: Improve HaveBuildTreeRPATH implementation
Use GetLinkImplementationLibraries instead of GetDirectLinkLibraries
because it tells us whether there will be any libraries to link after
evaluating generator expressions.  Also GetDirectLinkLibraries will be
dropped soon.
2014-06-23 09:22:08 -04:00
Brad King d912220eaa cmTarget: Lookup targets in LinkInterface and LinkImplementation
Instead of storing just the string names in these structures, lookup any
target associated with each item and store its cmTarget pointer.  Use
the cmLinkItem class to hold the name and pointer together.  Update
client sites to use the pre-stored lookup result instead of looking up
the target name again.

Create a cmTarget::LookupLinkItems helper method to handle the lookup.
Since lookups are now moving from cmComputeLinkDepends::AddLinkEntries
to cmTarget::LookupLinkItems, move use of CheckCMP0004 to the latter.
This drops use of CheckCMP0004 from entries added for _LIB_DEPENDS
variables by cmComputeLinkDepends::AddVarLinkEntries, but I do not
think that use was intentional originally anyway.
2014-06-23 09:22:07 -04:00
Brad King 097be4139d cmTarget: Add GetUtilityItems to get target ordering dependencies
Add a method like GetUtilities but that provides the target names
already looked up and resolved to cmTarget pointers internally.  Update
call site in cmComputeTargetDepends::AddTargetDepend to use the
already-found target instead of looking it up again.
2014-06-23 09:21:56 -04:00
Brad King a272344228 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.
2014-06-23 09:17:07 -04:00
Brad King 069d60fe03 cmTarget: Add method to lookup other targets in a target's scope
Move the main implementation of cmComputeLinkDepends::FindTargetToLink
into cmTarget.
2014-06-23 09:17:06 -04:00
Brad King 47ab3ca641 cmTarget: Constify GetLinkImplementationClosure results
Populate a vector of "cmTarget const*" instead of "cmTarget*".
2014-06-23 09:17:06 -04:00
Brad King 9f3ed029ce cmTarget: Constify GetTransitivePropertyTargets results
Populate a vector of "cmTarget const*" instead of "cmTarget*".
2014-06-23 09:17:06 -04:00
Brad King 6f0951af01 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.
2014-06-23 09:17:06 -04:00
Brad King 0dc9e88d76 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.
2014-06-23 09:17:00 -04:00
Brad King 4ac72455fd cmTarget: Drop 'head' argument from GetLinkClosure
It is only ever passed the 'this' target itself.
2014-06-23 09:14:45 -04:00
Brad King bcdb7ff9df 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>
2014-06-23 09:14:45 -04:00
Brad King bd9b667bbe cmComputeLinkInformation: Remove 'head' argument
It is only ever constructed with the current target as its own 'head'.

Co-Author: Stephen Kelly <steveire@gmail.com>
2014-06-23 09:14:45 -04:00
Brad King 06328dd58e cmTarget: Remove 'head' argument from GetLinkInformation
No call sites use it anyway.

Co-Author: Stephen Kelly <steveire@gmail.com>
2014-06-23 09:14:45 -04:00
Brad King 56aed7005a cmTarget: Cache GetLinkImplementationClosure results
Store them internally and return by reference to avoid duplicate
computation.
2014-06-23 09:14:44 -04:00
Brad King cbf689c7dd 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.
2014-06-23 09:14:44 -04:00
Brad King 2f0004c143 cmTarget: Remove 'head' argument from GetTransitiveTargetClosure
The method is never called with any headTarget besides "this".
2014-06-23 09:14:44 -04:00
Brad King e838e0a977 cmTarget: Simplify processILibs implementation
Combine the outer two if() conditions into a single one with &&.
Scope inner lookup result inside its condition.
2014-06-23 09:14:43 -04:00
Brad King 8d15a1bbfb 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.
2014-06-23 08:50:08 -04:00
Brad King 6354df92b1 cmTarget: Remove unused GetInterfaceLinkLibraries method 2014-06-23 08:50:08 -04:00
Brad King 2944bf164e Merge topic 'android-platform'
42f74df6 Add basic Android platform module
2014-06-10 09:17:39 -04:00
Ben Boeckel 1b003c1f95 cmTarget: Remove an unused variable 2014-06-09 14:45:35 -04:00
Brad King 42f74df6d4 Add basic Android platform module
Create a Platform/Android module that includes Platform/Linux since
Android is based on Linux.  Provide only the minimal settings needed to
get builds with Android NDK toolchains to work.

Disable use of RPATH since the Android loader ignores it and we cannot
predict the install destination anyway.

Android supports soname but shared library names must end in ".so" and
we cannot represent the versioned names with associated symlinks on all
host operating systems anyway.  However, we do want the SONAME of
library files to be set so that linking to them by path to the library
file produces NEEDED entries with the soname and not the path.  Add a
new CMAKE_PLATFORM_NO_VERSIONED_SONAME setting to tell the
cmTarget::GetLibraryNames method that not to use the VERSION or
SOVERSION target properties in the soname.
2014-06-06 14:03:42 -04:00
Ben Boeckel 2a1b2d8486 backtrace: Convert to local paths in IssueMessage
This is the only place we care show the FilePath to the user, so defer
the expensive relative path calculation until here.
2014-06-05 12:44:19 -04:00