Commit Graph

344 Commits

Author SHA1 Message Date
Brad King 16569abfa8 cmTarget: Track internally whether platform is Android
Add an IsAndroid member to save whether CMAKE_SYSTEM_NAME is "Android".
2014-09-29 16:05:53 -04:00
Brad King 7b743a2e76 cmTarget: Avoid re-computing head-independent link interfaces 2014-07-21 13:04:04 -04:00
Brad King 46099b82ed cmTarget: Move ComputeLinkImplementation* to internals
There are no external callers, and this will allow the methods to see
the full OptionalLinkImplementation internal structure.
2014-07-21 11:55:56 -04:00
Brad King 36a8184d40 Merge topic 'dev/target-fastpaths'
a9c9b66c cmTarget: use a hash_map for cmTargets typedef
bcb6dbc1 cmTarget: help the optimizer a bit
679f3dee cmTarget: use hash_set for sets of strings
23d6520d cmTarget: Allow caching of empty genex expansions
cd54f1db cmTarget: Only copy GenEx expansions when necessary
b75fc0e1 cmTarget: Don't set properties on custom targets
66076915 cmTarget: Use static strings for special property names
cebefa71 cmTarget: Sort special property checks
97ce676e cmTarget: Fast path for regular properties
4cfa918a cmTarget: Factor out common code
85242b7d cmTarget: Use else/if trees rather than an if tree
2014-07-18 11:00:29 -04:00
Ben Boeckel a9c9b66c27 cmTarget: use a hash_map for cmTargets typedef 2014-07-17 11:17:52 -04:00
Brad King c45dd669ab cmTarget: Cache compatible interface property sets
Replace isLinkDependentProperty with a CompatibleInterfaces structure
that records all the compatible interface properties in a set for each
type.  This avoids repeatedly traversing the link implementation closure
and asking every target for its compatible interface properties.
2014-07-16 13:38:22 -04:00
Brad King 0a8fbac19a cmTarget: Drop GetTransitivePropertyTargets method
Inline the implementation at the only remaining call site.
2014-07-16 13:31:29 -04:00
Brad King 535fd6ce6d cmTarget: Make GetLink*Libraries methods safer to use
Split the library lists out of LinkImplementation and LinkInterface into
LinkImplementationLibraries and LinkInterfaceLibraries parent classes,
respectively.  Return these from GetLinkImplementationLibraries and
GetLinkInterfaceLibraries, respectively, so that callers cannot access
parts of the structures that have not been populated.
2014-07-16 13:31:29 -04:00
Brad King a0dc1354fe Merge topic 'refactor-link-internals'
1ca0c0e9 cmTarget: Refactor internal imported LinkInterface map
102eea60 cmTarget: Simplify internal ComputeLinkInterfaceLibraries method
b0f57408 cmTarget: Move ComputeLinkInterfaceLibraries to internals
c69e8a55 cmTarget: Refactor internal LinkInterface map
4db3990e cmTarget: Drop 'head' argument from processSources
4b8130b8 cmTarget: Drop 'head' argument from GetSourceFiles
4c763dd1 cmTarget: Drop 'head' argument from GetLanguages
190cabe7 cmTarget: Drop 'head' argument from ComputeLinkImplementationLanguages
2014-07-16 13:04:21 -04:00
Brad King 8a205b980c cmTarget: Compile old-style link dependencies only for VS 6
Compile all the "ForVS6" cmTarget members only on Windows.  No other
platforms support the VS 6 generator.
2014-07-14 14:39:20 -04:00
Brad King b3b44d138e cmTarget: Rename old-style link dependencies code as "ForVS6"
The old link dependency analysis is now needed only for the VS 6
generator code delimited by CM_USE_OLD_VS6 to support project-provided
project templates.  Rename the related cmTarget members to be "ForVS6".
2014-07-14 14:37:04 -04:00
Brad King b0f5740851 cmTarget: Move ComputeLinkInterfaceLibraries to internals
There are no external callers, and this will allow the method to see
the full OptionalLinkInterface internal structure.
2014-07-14 09:55:52 -04:00
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 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 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
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 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 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 4dad5fd20b cmTarget: Add cmLinkItem to refer to a target by name and pointer
Many items named in target_link_libraries calls are targets, but not
all.  Create a cmLinkItem type that acts like std::string so it can name
an item but also has a pointer to a cmTarget that is the result of
looking up the item name in the referencing target's scope.  This will
be useful to avoid duplicate lookup operations later.
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 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 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 3ea9bde845 Merge topic 'ninja-intel-ipo'
b6e2e0d1 Ninja: Fix Intel interprocedural optimization with static libraries
5d12b87b cmGeneratorTarget: Improve GetCreateRuleVariable API
c2eeb08b cmTarget: Add GetFeatureAsBool method
2014-05-22 10:37:50 -04:00
Stephen Kelly 0dfe395e3c Features: Add COMPILE_FEATURES generator expression.
Allow setting build properties based on the features available
for a target.  The availability of features is determined at
generate-time by evaluating the link implementation.

Ensure that the <LANG>_STANDARD determined while evaluating
COMPILE_FEATURES in the link implementation is not lower than that
provided by the INTERFACE of the link implementation.  This is
similar to handling of transitive properties such as
POSITION_INDEPENDENT_CODE.
2014-05-21 17:22:32 +02:00
Brad King c2eeb08b06 cmTarget: Add GetFeatureAsBool method
Return the GetFeature method result converted to a boolean value.
2014-05-21 09:38:22 -04:00
Brad King 911cc9a39e cmTarget: Evaluate CMP0026 and CMP0051 in calling context
These policies should be checked at the call site that tries to access
the LOCATION or SOURCES property, not the directory scope containing the
target.  Thread the caller context through cmTarget::GetProperty to use
for checking the policy setting and emitting a diagnostic with proper
backtrace.

Extend the RunCMake.CMP0026 and RunCMake.CMP0051 tests with
cross-directory cases.
2014-05-09 11:24:15 -04:00
Brad King cb810abe6d cmTarget: Drop unused GetProperty signature
No callers use the second "scope" argument.  Drop this signature and
hard-code the default parameter value internally.
2014-05-09 11:17:32 -04:00
Brad King b56a9ae7f1 Merge topic 'target_compile_features'
9eaf3755 Export: Populate INTERFACE_COMPILE_FEATURES property.
8ed59fc2 Add target_compile_features command.
4e6ca504 cmTargetPropCommandBase: Change the interface to return bool.
5412dede cmTarget: Transitively evaluate compiler features.
baff4434 cmTarget: Allow populating COMPILE_FEATURES using generator expressions.
f97bf437 Features: Add cxx_auto_type.
03355d6b cmTarget: Add COMPILE_FEATURES target property.
faeddf64 project: Add infrastructure for recording CXX compiler features
913394af cmTarget: Add CXX_STANDARD and CXX_EXTENSION target properties.
8238a6cd Add some COMPILE_OPTIONS for specifying C++ dialect.
892243fc Tests: Require CMake 3.0 for the SystemInformation test.
59b5fdd3 Don't load Clang-CXX from AppleClang-CXX.
2014-04-15 10:32:11 -04:00
Stephen Kelly b8af201168 cmTarget: Fix listing of source files at configure-time.
Since commit e5da9e51 (cmTarget: Allow any generator expression in
SOURCES property., 2014-03-18), source files are computed by
true evaluation of generator expressions, including TARGET_OBJECTS.
This evaluation requires the presence of cmGeneratorTarget objects
since commit bf98cc25 (Genex: Evaluate TARGET_OBJECTS as a normal
expression., 2014-02-26).

Ensure that we don't attempt to evaluate the TARGET_OBJECTS generator
expression at configure-time, as can happen if CMP0024 or CMP0026
are OLD.  Use old-style parsing of the source item to extract
object target names in that case.

Avoid calling GetProperty("SOURCES") to bypass warnings from CMP0051.
Refactor existing logic in GetLanguages which is similar in intent to
the new GetSourceFiles code.
2014-04-13 10:59:50 +02:00
Brad King 5c63c13190 Merge topic 'install-prefix-in-interface'
783bce29 Export: Disallow exported interface includes in src/build tree (#14592).
c869984e RunCMake: Allow specifying the source dir and file to test.
2014-04-10 09:53:13 -04:00
Stephen Kelly 783bce295b Export: Disallow exported interface includes in src/build tree (#14592).
Allow directories in the source tree or build tree only if the
install tree is a subdirectory of the source tree or build tree,
as appropriate.

Re-use the test files in the RunCMake.include_directories test
to run in multiple scenarios.  Bump the required CMake version
in the test to 3.0 to ensure that the new policy warnings are
emitted correctly.
2014-04-09 10:38:49 +02:00
Stephen Kelly 4f1c71fdd2 cmTarget: Add all sources traced from custom commands at once.
The AddSource method accepts one file and tries to avoiding adding
it to the sources-list of the target if it already exists.  This
involves creating many cmSourceFileLocation objects for matching
on existing files, which is an expensive operation.

Avoid the searching algorithm by appending the new sources as one
group.  Generate-time processing of source files will ensure
uniqueness.

Add a new AddTracedSources for this purpose.  The existing
AddSources method must process the input for policy CMP0049, but
as these source filenames come from cmSourceFile::GetFullPath(),
we can forego that extra processing.
2014-04-09 10:37:00 +02:00
Stephen Kelly b1c3ae33ea cmTarget: Short-circuit language computation if context independent.
Computing the language involves computing the source files, which
is an expensive operation.  It requires calling
cmMakefile::GetOrCreateSource many times, which involves creating
and matching on many cmSourceFileLocation objects.

Source files of a target may depend on the head-target and the
config as of commit e6971df6 (cmTarget: Make the source files depend
on the config., 2014-02-13).  The results are cached for each context
as of commit c5b26f3b (cmTarget: Cache the cmSourceFiles in
GetSourceFiles., 2014-04-05).

Each target in the build graph causes language computation of all
of its dependents with itself as the head-target.  This means that
for 'core' libraries on which everything depends, the source files
are computed once for every transitive target-level-dependee and
the result is not cached because the head-target is different. This
was observed in the VTK buildsystem.

Short circuit the computation for targets which have a source-list
that is independent of the head-target.  If the source-list has
already been computed and the generator expression evaluation
reports that it was context-independent, return the only source-list
already cached for the target.  Reset the short-circuit logic when
sources are added and when the link libraries are re-computed.
2014-04-09 10:37:00 +02:00
Stephen Kelly 5412deded1 cmTarget: Transitively evaluate compiler features.
Extend the interface of the target_compile_features command with
PUBLIC and INTERFACE keywords. Populate the INTERFACE_COMPILER_FEATURES
target property if they are set. Consume the INTERFACE_COMPILER_FEATURES
target property from linked dependent targets to determine the final
required compiler features and the compile flag, if needed.

Use the same pattern of origin-debugging which is used for other
build properties.
2014-04-07 18:11:18 +02:00
Stephen Kelly baff44345c cmTarget: Allow populating COMPILE_FEATURES using generator expressions.
Delay validation of the content as a feature if it contains a
generator expression. It will be checked again at generate-time
after evaluation.
2014-04-07 18:11:18 +02:00