Commit Graph

181 Commits

Author SHA1 Message Date
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
Brad King 571d050415 Merge topic 'fix-mapped-config-genex'
10a069b Genex: Fix $<CONFIG> with IMPORTED targets and multiple locations.
2013-07-24 11:02:19 -04:00
Stephen Kelly 10a069b504 Genex: Fix $<CONFIG> with IMPORTED targets and multiple locations.
The old code checked only that there was a LOCATION for the
specified config, but did not check whether the config actually
mapped.

Task-number: 14292
2013-07-24 10:43:02 -04:00
Stephen Kelly 4f6bd7022b Remove the LINK_LANGUAGE generator expression.
It accepted an optional argument to test for equality, but no way
to get the linker language of a particular target.

TARGET_PROPERTY provides this flexibility and STREQUAL provides
the necessary API for equality test.

Extend the CompileDefinitions test to cover accessing the
property of another target.
2013-07-24 10:40:00 -04:00
Brad King 41a2fb5ba0 Merge topic 'tid-system-argument'
9cf3547 Add the INTERFACE_SYSTEM_INCLUDE_DIRECTORIES target property.
1925cff Add a SYSTEM parameter to target_include_directories (#14180)
286f227 Extend the cmTargetPropCommandBase interface property handling.
83498d4 Store system include directories in the cmTarget.
f1fcbe3 Add Target API to determine if an include is a system include.
2679a34 Remove unused variable.
2013-07-16 13:59:07 -04:00
Stephen Kelly 9cf3547e1c Add the INTERFACE_SYSTEM_INCLUDE_DIRECTORIES target property.
Unlike other target properties, this does not have a corresponding
non-INTERFACE variant.

This allows propagation of system attribute on include directories
from link dependents.
2013-07-16 13:44:57 -04:00
Stephen Kelly 484bb888a0 Genex: Make CMP0021 and CMP0022 usable with TARGET_POLICY
Use preprocessor loops and add a unit test for the appropriate
policies. All policies whose value is recorded at target creation
time should be part of this list.
2013-07-11 11:56:14 +02:00
Stephen Kelly ddde61c0b2 Introduce the LINK_ONLY generator expression.
This is an internal expression for use by target_link_libraries
for static libraries.
2013-07-08 00:00:18 +02:00
Stephen Kelly 5aa9731c9f GenexEval: Add abstracted access to link interface for a target.
This can be extended with special handling for static libraries
so that we can process the link dependencies separately from the
usage dependencies.
2013-07-08 00:00:17 +02:00
Stephen Kelly 47a8db5bcd Add generator expressions for compiler versions.
New generator expressions allow retrieval of the version per language,
as well as equality comparison.
2013-06-28 14:32:58 +02:00
Brad King bef7c0251e Merge topic 'dag-LINKER_LANGUAGE'
ff015ee Genex: Report error if a target file is needed to evaluate link libraries.
b58aff9 Genex: Extend EvaluatingLinkLibraries to also check the top target name.
b1c19ce Genex: Make LINK_LANGUAGE report an error when evaluating link libraries.
0e1cb07 Add missing return after error report.
2013-06-26 09:03:05 -04:00
Brad King c1631efa0e Merge topic 'version-compare-genex'
e605528 Add generator expressions for version comparision.
48bb48e De-duplicate version comparison code.
2013-06-26 09:02:49 -04:00
Stephen Kelly ff015ee11e Genex: Report error if a target file is needed to evaluate link libraries.
Constructs such as

 target_link_libraries(foo $<$<STREQUAL:$<TARGET_FILE:foo>,foo.so>:bar>)

segfault before this patch.
2013-06-24 16:22:15 +02:00
Stephen Kelly b1c19ce383 Genex: Make LINK_LANGUAGE report an error when evaluating link libraries. 2013-06-24 16:21:53 +02:00
Stephen Kelly 0e1cb07e84 Add missing return after error report. 2013-06-24 16:21:53 +02:00
Brad King 0fd7d47138 Merge topic 'transitive-property-PP-FOR_EACH'
0d8db25 Use a preprocessor loop to manage the valid transitive properties.
2013-06-24 08:46:46 -04:00
Stephen Kelly e6055284b3 Add generator expressions for version comparision. 2013-06-12 14:09:36 +02:00
Stephen Kelly e3b7eac593 Style: Don't put an else after a return. 2013-06-11 10:50:00 +02:00
Stephen Kelly 0d8db250ce Use a preprocessor loop to manage the valid transitive properties.
Hopefully this will prevent regressions when adding further transitive
properties in the future.
2013-06-10 16:13:21 +02:00
Brad King d3c8688ecd Merge topic 'fix-genex-HEAD-target'
5b22235 Genex: Fix the HEAD target used for evaluated expressions
2013-06-05 09:54:20 -04:00
Stephen Kelly 5b222354de Genex: Fix the HEAD target used for evaluated expressions
If the expression $<TARGET_PROPERTY:prop> appears in the content
of a target property, the target that prop is read from is
the 'head target' of the expression. In contexts such as evaluating
the content of a target property during generation, such
as INCLUDE_DIRECTORIES, the 'head target' is the one on which the
initial request was made.

If evaluating a generator expression which is not a target property
content, the target must be explicitly specified. Such contexts
include add_custom_command and file(GENERATE). The content might
then look like

 $<TARGET_PROPERTY:tgt,prop>

However, as there is no HeadTarget set, any generator expressions
evaluated as part of reading prop from tgt which do not specify
the tgt directly report an error.

Modify the logic of the TARGET_PROPERTY generator expression so
that in such contexts, the 'head target' is set to the appropriate
target which was first encountered.
2013-06-05 09:05:00 -04:00
Stephen Kelly 80ca9c4b41 Add COMPILE_OPTIONS target property.
This method reads generator expressions from the COMPILE_OPTIONS
target property, as well as INTERFACE_COMPILE_OPTIONS from linked
dependents.
2013-06-02 11:56:37 +02:00
Stephen Kelly 1319a147bd Add <LANG>_COMPILER_ID generator expressions.
These expressions evaluate to the id of the compiler used to build
the target, or can be used to test if the compiler id matches a
specified value.
2013-06-02 11:56:36 +02:00
Brad King 7b8a4c3e6f Merge topic 'fix-INCLUDE_DIRECTORIES-genex-read'
3aa9ce4 GenexEval: Fix evaluation of INCLUDE_DIRECTORIES target property.
0b39fef GenexEval: Extract a getLinkedTargetsContent from TargetPropertyNode.
53164ac cmTarget: Remove some hardcoding of transitive property names.
2013-05-31 09:33:22 -04:00
Stephen Kelly 3aa9ce441f GenexEval: Fix evaluation of INCLUDE_DIRECTORIES target property.
This property should come from the content of the property itself,
plus the INTERFACE_INCLUDE_DIRECTORIES of the link *implementation*.

In contrast, when the INTERFACE_INCLUDE_DIRECTORIES is evaluated for
a target, the INTERFACE_INCLUDE_DIRECTORIES of the link *interface*
is used.

Similar logic applies for the COMPILE_DEFINITIONS target properties.

If the propertyName is already an INTERFACE_ variant of the property,
ie, the expression is similar to

 $<TARGET_PROPERTY:foo,INTERFACE_INCLUDE_DIRECTORIES>

then the INTERFACE_INCLUDE_DIRECTORIES of the link *interface* of foo
is used.

However, if the propertyName is not an INTERFACE_ variant, and the
interfacePropertyName is, ie, the expression is similar to:

 $<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>

then the INTERFACE_INCLUDE_DIRECTORIES of the link *implementation*
of foo is used.
2013-05-30 15:43:42 +02:00
Stephen Kelly 0b39fefeac GenexEval: Extract a getLinkedTargetsContent from TargetPropertyNode.
This will be used to process transitive components of properties
which depend on linked targets. Currently only the link interface
of the target can be used as the source of the linked targets, but
in the next commit it will be possible to use the link implementation
as the source of link targets.

This commit does not change the semantics of the code.
2013-05-30 15:43:42 +02:00
Stephen Kelly 53164ac997 cmTarget: Remove some hardcoding of transitive property names. 2013-05-30 15:43:37 +02:00
Brad King 14d90d81de Merge topic 'language-generator-expressions'
3241014 Add $<LINK_LANGUAGE> generator expression
2013-05-24 09:19:15 -04:00
Stephen Kelly 32410140a7 Add $<LINK_LANGUAGE> generator expression
They can't be used when evaluating link libraries, but they can be
used for include directories and compile definitions. Later they can
be used for compile options.
2013-05-24 09:06:53 -04:00
Brad King 3db29d2724 Merge topic 'join-genex'
a7ba452 Add the JOIN generator expression.
96ec314 Make it possible for any genex to have arbitrary content at the end.
bd638ee Rename the method determining if a genex accepts arbitrary content.
dc742fe Extract the ProcessArbitraryContent method.
2013-05-22 13:35:15 -04:00
Brad King d2cd362c31 Merge topic 'fix-genex-comma-parse'
05bf972 Fix handling of commas in arbitrary content in genexes.
2013-05-21 15:19:26 -04:00
Stephen Kelly 44258cc26c Remove unused typedef. 2013-05-17 09:01:01 +02:00
Stephen Kelly a7ba4520c7 Add the JOIN generator expression.
This generator expression joins a list with a separator. The separator
may contain arbitrary content, such as commas, which is ordinarily a
delimiter in the generator expression syntax.
2013-05-16 19:36:31 +02:00
Stephen Kelly 96ec3147bb Make it possible for any genex to have arbitrary content at the end. 2013-05-16 19:36:31 +02:00
Stephen Kelly bd638ee20f Rename the method determining if a genex accepts arbitrary content.
The meaning of this will be expanded to generator expressions with
more than a single parameter.
2013-05-16 19:36:31 +02:00
Stephen Kelly dc742fe4be Extract the ProcessArbitraryContent method. 2013-05-16 19:36:31 +02:00
Stephen Kelly 05bf9721e4 Fix handling of commas in arbitrary content in genexes.
As the comma is the parameter separator, it needs to be re-added
when evaluating to reconstruct arbitrary content.
2013-05-16 19:25:06 +02:00
Jean-Christophe Fillion-Robin 7f3bb8b392 Add $<SEMICOLON> generator expression.
This expression is useful to put a ';' in a command line argument
without dividing the argument during CMake list expansion.
2013-03-12 16:46:03 -04:00
Brad King b4bb074d8b Merge topic 'remove-TARGET_DEFINED-genex'
cbf0756 Revert "Add the TARGET_DEFINED generator expression"
21a342c Remove use of TARGET_DEFINED from the target_link_libraries test.
47b8d32 Remove use of TARGET_DEFINED from the ExportImport test.
2e39d21 Remove use of TARGET_DEFINED from target_include_directories test.
2013-03-04 15:39:45 -05:00
Brad King 57072c12d2 Merge topic 'interface-property-external-read'
8dfdf1c Fix the tests for evaluating includes and defines.
98a6725 Fix constness of accessors.
7e70744 Expand includes and defines transitively in 'external' genexes.
d1a2729 Fix DAG checker finding cycling dependencies.
e72eaad Workaround broken code where a target has itself in its link iface.
ec2c67b Strip stray semicolons when evaluating generator expressions.
2013-02-25 13:12:12 -05:00
Stephen Kelly cbf07569ed Revert "Add the TARGET_DEFINED generator expression"
This reverts commit 2bee6f5ba5.

This expression is not used, and has a semantic which is not completely
optimal (namely considering utility targets to be targets, though
usually we are interested in linkable targets).

Remove it so that we have more freedom to define better expressions in
the future.

Conflicts:
        Source/cmGeneratorExpressionEvaluator.cxx
        Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
        Tests/CMakeCommands/target_compile_definitions/consumer.cpp
2013-02-25 15:35:11 +01:00
Stephen Kelly 7e707444be Expand includes and defines transitively in 'external' genexes.
This means that we can use expressions of the form

 $<TARGET_PROPERTY:foo,INTERFACE_INCLUDE_DIRECTORIES>

to get a list of the interface include directories of foo, including
those coming from dependencies.

We can't have a test of a target which has a single include directory in
its INCLUDE_DIRECTORIES because the shell on the MSYS platforms transforms
a single include directory to include a prefix, which is not what the test
expects. We test a target with two directories instead as a means to
test a target with no link dependencies.
2013-02-23 09:42:24 +01:00
Stephen Kelly e72eaadc42 Workaround broken code where a target has itself in its link iface.
There is a test for this since commit 8e756d2b (Tolerate cycles in
shared library link interfaces (#12647), 2012-01-12), so make sure
it continues to pass, even as we require no self-references in new
INTERFACE_ property generator expressions.
2013-02-23 09:41:22 +01:00
Stephen Kelly f2ab17d4db Keep track of all targets seen while evaluating a genex.
As dependencies of the generator expression, these will re-exported
in try_compile generated code.
2013-02-22 08:35:29 -05:00
Stephen Kelly ec2c67bcf3 Strip stray semicolons when evaluating generator expressions. 2013-02-18 12:07:32 +01:00
Stephen Kelly 3df36b5954 Revert "Add the $<LINKED:...> generator expression."
This reverts commit 0b92602b81.

Conflicts:
	Source/cmGeneratorExpressionEvaluator.cxx
	Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
	Tests/CMakeCommands/target_include_directories/CMakeLists.txt
2013-02-13 15:12:31 +01:00
Stephen Kelly 567c8d103e Revert "Don't allow utility or global targets in the LINKED expression."
This reverts commit 9712362b45.
2013-02-13 15:12:31 +01:00
Stephen Kelly a1c4905f72 Use the link information as a source of compile definitions and includes.
After evaluating the INTERFACE_INCLUDE_DIRECTORIES, of a target in a
generator expression, also read the INTERFACE_INCLUDE_DIRECTORIES of
its link interface dependencies.

That means that code such as this will result in the 'user' target
using /bar/include and /foo/include:

 add_library(foo ...)
 target_include_directories(foo INTERFACE /foo/include)
 add_library(bar ...)
 target_include_directories(bar INTERFACE /bar/include)
 target_link_libraries(bar LINK_PUBLIC foo)

 add_executable(user ...)
 target_include_directories(user PRIVATE
    $<TARGET_PROPERTY:bar,INTERFACE_INCLUDE_DIRECTORIES>)

Also process the interface include directories from direct link
dependencies for in-build targets.

The situation is similar for the INTERFACE_COMPILE_DEFINITIONS. The
include directories related code is currently more complex because
we also need to store a backtrace at configure-time for the purpose
of debugging includes. The compile definitions related code will use
the same pattern in the future.

This is not a change in behavior, as existing code has the same effect,
but that existing code will be removed in follow-up commits.
2013-02-13 15:12:30 +01:00
Stephen Kelly 9712362b45 Don't allow utility or global targets in the LINKED expression.
The LINKED expression is exclusively for handling INTERFACE content
and it does not make sense for utility targets to have INTERFACE
content.
2013-02-08 21:44:11 +01:00
Stephen Kelly d4e5c6787c Don't keep track of content determined by target property values.
This tracking was added during the development of commit 042ecf04
(Add API to calculate link-interface-dependent bool properties
or error., 2013-01-06), but was never used.

It was not necessary to use the content because what is really
useful in that logic is to determine if a property has been implied
to be null by appearing in a LINK_LIBRARIES genex.

I think the motivating usecase for developing the feature of
keeping track of the targets relevant to a property was that I
thought it would  make it possible to allow requiring granular
compatibility of interface properties only for targets which
depended on the interface property. Eg:

 add_library(foo ...)
 add_library(bar ...)

 add_executable(user ...)
 # Read the INTERFACE_POSITION_INDEPENDENT_CODE from bar, but not
 # from foo:
 target_link_libraries(user foo $<$<TARGET_PROPERTY:POSTITION_INDEPENDENT_CODE>:bar>)

This obviously doesn't make sense. We require that INTERFACE
properties are consistent across all linked targets instead.
2013-02-07 16:21:09 +01:00
Stephen Kelly 1fb545ad3a Move a special case for PIC from the genex to the cmTarget code. 2013-02-07 16:21:09 +01:00
Stephen Kelly 57175d559e Only use early evaluation termination for transitive properties.
We need to make sure expressions which evaluate TARGET_PROPERTY:TYPE
multiple times for example get the correct result each time, and
not an empty string instead.
2013-02-07 16:21:09 +01:00
Stephen Kelly 7c0ec75cfa De-duplicate validation of genex target names. 2013-02-07 16:21:08 +01:00
Stephen Kelly e48d84209c Cache context-independent includes on evaluation.
Generator expressions whose output depends on the configuration
now record that fact. The GetIncludeDirectories method can use
that result to cache the include directories for later calls.

GetIncludeDirectories is called multiple times for a target
for each configuration, so this should restore performance for
multi-config generators.
2013-02-03 23:04:03 +01:00
Stephen Kelly 089fe1c13d Optimize genex evaluation for includes and defines.
While porting boost to use these features, the generation step took
too long (several minutes before I stopped it). The reason was that
the boost libraries form a large interdependent mesh. The libraries
list their dependencies in their INTERFACE such as:

 $<LINKED:boost::core>;$<LINKED:boost::config>;$<LINKED:boost::mpl>

As boost::core already depends on the boost::config libraries, that
expression has no impact on the end-content, as it is removed after
the generation step. There is no DAG issue though, so the generator
expression evaluation would fully evaluate them. In the case of the
config library, it also depends on the core library, so all depends
are followed through that again, despite the fact that they've just
been evaluated. After this patch, the evaluation skips libraries if
they have already been seen via depends or directly in the content.

This patch keeps track of targets whose INTERFACE has been consumed
already. The INCLUDE_DIRECTORIES and COMPILE_DEFINITIONS properties
are whitelisted because repeated content will be stripped out later
during generation. For other properties now and in the future, that
may not be the case.
2013-02-02 15:06:53 +01:00
Stephen Kelly 0b92602b81 Add the $<LINKED:...> generator expression.
This is both a short form of using a TARGET_DEFINED expression
together with a TARGET_PROPERTY definition, and a way to strip
non-target content from interface properties when exporting.
2013-01-31 17:34:20 +01:00
Stephen Kelly df4d2b28b2 Make it an error for INSTALL_PREFIX to be evaluated.
An empty string is not likely going to produce expected results
in any evaluation context. It is replaced by preprocessing
currently.
2013-01-31 17:27:06 +01:00
Stephen Kelly 30268b46f8 Handle reading empty properties defined by the link interface.
This was segfaulting before.
2013-01-31 11:18:49 +01:00
Stephen Kelly 34d1ade048 Add the INSTALL_PREFIX genex. 2013-01-27 09:59:26 +01:00
Stephen Kelly 2fb2c32f9b Add the COMPATIBLE_INTERFACE_STRING property. 2013-01-24 20:36:04 +01:00
Brad King a37b0e3ebf Merge topic 'qt4-autolink-qtmain'
e3b5eb6 Automatically link to the qtmain library when linking to QtCore.
6c8d8af Add the $<TARGET_POLICY> expression
2013-01-23 15:11:24 -05:00
Stephen Kelly e3b5eb6b23 Automatically link to the qtmain library when linking to QtCore.
When using QAxServer, ensure that the qtmain library is excluded
by reporting an error at CMake time if it is not.
2013-01-23 14:15:41 -05:00
Stephen Kelly e98799105b Make INTERFACE determined properties readable in generator expressions.
The properties are evaluated as link-dependent interface properties when
evaluating the generator expressions.
2013-01-20 17:06:47 +01:00
Stephen Kelly 6c8d8afe34 Add the $<TARGET_POLICY> expression
This new expression allows checking how a policy was set when a target
was created.  That information is only recorded for a subset of policies,
so a whitelist is used.
2013-01-17 17:20:17 +01:00