Commit Graph

144 Commits

Author SHA1 Message Date
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 9f3ed029ce cmTarget: Constify GetTransitivePropertyTargets results
Populate a vector of "cmTarget const*" instead of "cmTarget*".
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
Ben Boeckel 7492a7b846 regex: Search on strings where possible 2014-06-09 14:45:35 -04:00
Ben Boeckel 3e7194a215 regex: Use static regexs where possible
Rather than declaring and compiling a constant regex every time a chunk
of code is executed, build the regex once.
2014-06-09 14:45:35 -04:00
Ben Boeckel a08292059e genex: remove the need for backtraces
Rather than making dummy backtraces and passing them around, just make
backtraces optional.
2014-06-05 12:44:18 -04:00
Stephen Kelly fb2fa47656 Genex: Clarify error message on use with non-binary targets (#14899). 2014-05-29 11:29:31 +02: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 5376151aa1 Merge topic 'target-transitive-sources'
9407174b target_sources: New command to add sources to target.
81ad69e0 Make the SOURCES target property writable.
6e636f2e cmTarget: Make the SOURCES origin tracable.
3676fb49 cmTarget: Allow transitive evaluation of SOURCES property.
e6971df6 cmTarget: Make the source files depend on the config.
df753df9 cmGeneratorTarget: Don't add computed sources to the target.
869328aa cmComputeTargetDepends: Use valid config to compute target depends.
2014-04-03 12:51:53 -04:00
Stephen Kelly 3676fb4963 cmTarget: Allow transitive evaluation of SOURCES property.
Extend the cmGeneratorExpressionDAGChecker with an interface
returning the name of the top target.  Use that to determine
when there is a DAG violation, as required by the RunCMake.Languages
tests.
2014-04-02 23:14:02 +02:00
Stephen Kelly e6971df6ab cmTarget: Make the source files depend on the config.
Disallow the use of config-specific source files with
the Visual Studio and Xcode generators. They don't have
any way to represent the condition currently.

Use the same common-config API in cmQtAutoGenerators. While
it accepts config-specific files, it doesn't have to support
multiple configurations yet.

Loop over the configs in cmTargetTraceDependencies
and cmGlobalGenerator::WriteSummary and consume all source
files.

Loop over the configs in cmComputeTargetDepends and compute the
object library dependencies for each config.
2014-04-02 23:14:02 +02:00
Stephen Kelly 5de63265e3 Genex: Only evaluate TARGET_OBJECTS to determine target sources.
The output of this expression may contain macros for IDEs to replace
such as $(Configuration), $(CURRENT_ARCH) etc.  To avoid generating
content which is not usable in other contexts, report an error if
there is an attempt to use it in other contexts.

This commit may be reverted in the future if a solution to the
above difference is implemented.
2014-04-02 23:12:57 +02:00
Stephen Kelly bf98cc252f Genex: Evaluate TARGET_OBJECTS as a normal expression. 2014-03-31 23:18:44 +02:00
Stephen Kelly 21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Ben Boeckel 84fdc9921c stringapi: Pass configuration names as strings 2014-03-08 13:05:36 -05:00
Ben Boeckel ce5114354c stringapi: Use strings for the languages 2014-03-08 13:05:30 -05:00
Ben Boeckel 24e8b929ee genex: Store predicates as a map for faster searching
May warrant a fast path for predicates which more frequently.
2014-03-08 13:05:29 -05:00
Stephen Kelly b8b99cc1e5 cmTarget: Avoid computing languages when computing transitive targets.
For the OLD CMP0022 behavior, we need to treat the implementation
as the interface when computing the interface libraries.  Make it
possible to do that without computing the link languages by adding
a new GetLinkImplementationLibraries method.  Extend the existing
GetLinkImplementation method to populate the languages if the
libraries have already been computed and cached.

Change GetTransitivePropertyTargets to invoke GetLinkInterfaceLibraries
instead of GetLinkInterface.  This is key, as it is a method called
by cmGeneratorExpressionEvaluator.

Change the cmGeneratorExpressionEvaluator to invoke
GetLinkImplementationLibraries instead of GetLinkImplementation.
2014-02-24 16:43:24 +01:00
Stephen Kelly 21e91350b0 cmTarget: Change GetTransitivePropertyLinkLibraries to output targets.
The callers already skip non-targets, so unify the target search.

Change supporting functions to accept a container of targets instead
of strings where possible.
2014-02-24 16:43:23 +01:00
Rolf Eike Beer c768e398f9 cmMakefile: make some methods take const std::string& instead of const char*
Most callers already have a std::string, on which they called c_str() to pass it
into these methods, which internally converted it back to std::string. Pass a
std::string directly to these methods now, avoiding all these conversions.
Those methods that only pass in a const char* will get the conversion to
std::string now only once.
2014-01-16 09:28:29 -05:00
Stephen Kelly 6aabb6a62b Genex: Use case-sensitive comparison for COMPILER_ID. 2014-01-08 16:41:34 +01:00
Stephen Kelly 5bb53f6b73 cmTarget: Deprecate COMPILE_DEFINITIONS_ properties with a policy. 2014-01-08 16:41:34 +01:00
Stephen Kelly 3917d86b26 Genex: Add a nullary form for CONFIG
This is consistent with other similar expressions such as PLATFORM_ID,
and makes the CONFIGURATION expression obsolete.

Fix an off-by-one error in
GeneratorExpressionContent::EvaluateParameters exposed by a unit test.

Remove the test for 'bad' nullary use of $<CONFIG>.

Add a unit test to verify that $<CONFIG> and $<CONFIGURATION> have
the same value.
2014-01-07 09:38:01 -05:00
Stephen Kelly 9c9f69fb9c Genex: Make EQUAL support upper case binary literals
As C++11, python, D and java do.

 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3472.pdf

Add test for uppercase hex literals.
2014-01-06 18:46:45 +01:00
Stephen Kelly 6eb3218105 Genex: Fix case of methods in the dag checker. 2014-01-06 18:46:45 +01:00
Stephen Kelly 0f3e8e957f Undefine local preprocessor loop variables.
Most occurances of this pattern already contain the undef, so add it to
the rest too.
2014-01-06 17:25:10 +01:00
Stephen Kelly 9ba47ee49b Genex: Reform error-checking for nullary/unary expressions.
The error messages were incorrect (reporting that the expression
requires one or two parameters), and repeated.  Remove the now-unused
ZeroOrMoreParameters enum value.
2014-01-06 17:25:10 +01:00
Stephen Kelly 2af966d9ab Genex: Add EQUAL expression.
Support decimal, hex, octal and binary literals.
2014-01-06 17:25:09 +01:00
Stephen Kelly 2eda924389 Genex: Use case-sensitive comparison in PLATFORM_ID. 2013-12-19 16:17:59 +01:00
Stephen Kelly 9436353f94 Genex: Always return immediately on error. 2013-12-19 16:17:59 +01:00
Stephen Kelly f4d9466130 Genex: Accept arbitrary content in *_CASE and MAKE_C_IDENTIFIER. 2013-12-19 16:17:59 +01:00
Stephen Kelly d36b489401 Genex: Allow single param expressions to accept arbirary input.
Existing single-parameter expressions work due to special casing
which assumes that if there is only one parameter, and the node
accepts arbitrary content, then the result is the input.

This is true for the existing expressions matching that
pattern - namely the "1" and "TARGET_NAME" expressions. However,
the LOWER_CASE, and UPPER_CASE expressions should also accept
arbitrary content, and in their case, the result is not the input.

Refactor the cmGeneratorExpressionEvaluator to allow that extension.
Actually evaluate the "1" and "0" nodes.
2013-12-19 16:17:59 +01:00
Stephen Kelly 1242f4e569 Genex: Add {UPPER,LOWER}_CASE and MAKE_C_IDENTIFIER. 2013-11-27 19:06:12 +01:00
Stephen Kelly 0bfcb450e6 INTERFACE_LIBRARY: Avoid codepaths which set unneeded properties.
As an INTERFACE_LIBRARY has no direct link dependencies, we can
short-circuit in cmGeneratorExpressionEvaluator and
in cmGlobalGenerator::CheckLocalGenerators.

As they do not generate any output directly, any generate- or install-
related code acn also be short-circuited. Many of the local generators
already do this.

Because only INTERFACE related properties make sense on INTERFACE_LIBRARY
targets, avoid setting other properties, for example via defaults.
2013-11-25 16:17:50 +01:00
Stephen Kelly 4fe963f656 Use new cmHasLiteralPrefix function 2013-11-21 20:53:15 +01:00
Stephen Kelly 77a0fd5135 Genex: Use a preprocessor foreach to follow transitive properties. 2013-11-09 20:31:35 +01:00
Stephen Kelly 146493363e Genex: Simplify the preprocessor looper for interface properties.
By removing the INTERFACE_ prefix, we can use this in more contexts.
2013-11-09 20:31:35 +01:00
Brad King 872a9d6476 Merge topic 'object-library-no-TARGET_FILE'
d960589 Genex: Reject $<TARGET_FILE:...> for object libraries (#14532)
2013-11-02 10:54:23 -04:00
Brad King d960589778 Genex: Reject $<TARGET_FILE:...> for object libraries (#14532)
Teach the cmGeneratorExpressionEvaluator filesystem artifact logic
to reject OBJECT_LIBRARY targets since they have no main artifact.
Without the explicit rejection evaluation falls through to an
internal CMake error message in cmTarget::GetOutputInfo.

Extend the RunCMake.GeneratorExpression test to cover these cases.
2013-11-01 10:17:01 -04:00
Stephen Kelly c4373b33b2 cmTarget: Make GetProperty() const.
This has follow-on effects for other methods and classes. Further
work on making the use of const cmTarget pointers common can be
done, particularly with a view to generate-time methods.
2013-10-31 14:52:11 +01:00
Stephen Kelly ff6c401309 cmTarget: Add interface for compatible numeric properties
When using the boost MPL library, one can set a define to increase
the limit of how many variadic elements should be supported. The
default for BOOST_MPL_LIMIT_VECTOR_SIZE is 20:

 http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/limit-vector-size.html

If the foo library requires that to be set to 30, and the independent
bar library requires it to be set to 40, consumers of both need to set
it to 40.

 add_library(foo INTERFACE)
 set_property(TARGET foo PROPERTY INTERFACE_boost_mpl_vector_size 30)
 set_property(TARGET foo PROPERTY COMPATIBLE_INTERFACE_NUMBER_MAX boost_mpl_vector_size)
 target_compile_definitions(foo INTERFACE BOOST_MPL_LIMIT_VECTOR_SIZE=$<TARGET_PROPERTY:boost_mpl_vector_size>)

 add_library(bar INTERFACE)
 set_property(TARGET bar PROPERTY INTERFACE_boost_mpl_vector_size 40)
 # Technically the next two lines are redundant, but as foo and bar are
 # independent, they both set these interfaces.
 set_property(TARGET bar PROPERTY COMPATIBLE_INTERFACE_NUMBER_MAX boost_mpl_vector_size)
 target_compile_definitions(bar INTERFACE BOOST_MPL_LIMIT_VECTOR_SIZE=$<TARGET_PROPERTY:boost_mpl_vector_size>)

 add_executable(user)
 target_link_libraries(user foo bar)

Because the TARGET_PROPERTY reads the boost_mpl_vector_size property
from the HEAD of the dependency graph (the user target), and because
that property appears in the COMPATIBLE_INTERFACE_NUMBER_MAX of
the dependencies of the user target, the maximum value for it is
chosen for the compile definition, ie, 40.

There are also use-cases for choosing the minimum value of a number.
In Qt, deprecated API can be disabled by version. Setting the
definition QT_DISABLE_DEPRECATED_BEFORE=0 disables no deprecated
API. Setting it to 0x501000 disables API which was deprecated before
Qt 5.1 etc.

If two dependencies require the use of API which was deprecated in
different Qt versions, then COMPATIBLE_INTERFACE_NUMBER_MIN can be
used to ensure that both can compile.
2013-10-24 08:42:05 +02:00
Brad King 078530b448 Merge topic 'cmarray-templates'
d169b1f Genex: Use cmArraySize for targetPolicyWhitelist
86d5d80 Genex: Remove use of TransitiveWhitelistCompare
73d7705 Add some templates for cleaner array iteration.
2013-10-23 08:19:52 -04:00
Stephen Kelly d169b1f037 Genex: Use cmArraySize for targetPolicyWhitelist
For better readability.
2013-10-22 10:45:23 +02:00
Stephen Kelly 86d5d808c8 Genex: Remove use of TransitiveWhitelistCompare
Replace with generic solution based on cmArray* for better
readability.
2013-10-22 10:45:23 +02:00
Rolf Eike Beer a80fe4b1d2 use size_t for GeneratorExpressionContent::ContentLength to fix some warnings
CMake/Source/cmGeneratorExpressionParser.cxx: In member function ‘void cmGeneratorExpressionParser::ParseGeneratorExpression(std::vector<cmGeneratorExpressionEvaluator*>&)’:
CMake/Source/cmGeneratorExpressionParser.cxx:116:55: warning: conversion to ‘unsigned int’ from ‘long int’ may alter its value [-Wconversion]
CMake/Source/cmGeneratorExpressionParser.cxx:240:39: warning: conversion to ‘int’ from ‘long int’ may alter its value [-Wconversion]
2013-10-21 19:58:49 +02:00
Brad King 058af7a6ce Merge topic 'PLATFORM_ID-genex'
dcc00ec Genex: Add the PLATFORM_ID expression.
2013-10-07 15:41:39 -04:00
Stephen Kelly dcc00ece4b Genex: Add the PLATFORM_ID expression. 2013-08-28 10:23:20 +02:00
Stephen Kelly 15d98a42fd Genex: Fix evaluation of MAP_IMPORTED_CONFIG_<CONFIG>
Commit 10a069b5 (Genex: Fix $<CONFIG> with IMPORTED targets and
multiple locations., 2013-07-15) changed the logic here to include
handling of the MAP_IMPORTED_CONFIG_<CONFIG> target property, but
it was buggy in several ways.

Uppercase the configs in all cases, and compare the mapped configs
with the parameter to the CONFIG genex, instead of with the key of
the mapping.
2013-08-27 15:36:57 +02:00
Stephen Kelly 370bf55415 Add the ALIAS target concept for libraries and executables.
* The ALIAS name must match a validity regex.
* Executables and libraries may be aliased.
* An ALIAS acts immutable. It can not be used as the lhs
  of target_link_libraries or other commands.
* An ALIAS can be used with add_custom_command, add_custom_target,
  and add_test in the same way regular targets can.
* The target of an ALIAS can be retrieved with the ALIASED_TARGET
  target property.
* An ALIAS does not appear in the generated buildsystem. It
  is kept separate from cmMakefile::Targets for that reason.
* A target may have multiple aliases.
* An ALIAS target may not itself have an alias.
* An IMPORTED target may not have an alias.
* An ALIAS may not be exported or imported.
2013-08-02 15:21:00 +02:00
Stephen Kelly b8dc7fad23 Genex: Disallow LINKER_LANGUAGE only when used on a static library.
For shared libraries and executables, the linker_language is
indepenedent of the linked libraries.
2013-07-26 16:58:25 +02:00