Some commands on Windows do not understand forward slash paths and
require backslashes. In order to help projects generate shell
invocations of such commands, provide a generator expression to convert
paths to the shell-preferred path format for the current generator.
This will allow custom commands to generate paths the same way CMake
does for compiler command invocations.
Since support for generator expressions was added to OUTPUT_NAME it is
possible for project code to cause recursion in this method by using a
$<TARGET_FILE> genex. Detect and reject such cases.
If {ARCHIVE,LIBRARY,RUNTIME}_OUTPUT_DIRECTORY is set with a genex then
do not add the per-config subdirectory on multi-config generators.
This will allow projects to use $<CONFIG> to place the per-config
part of the directory path somewhere other than the end.
For complex*, CustomCommand and OutDir tests, non-ascii paths
are avoided in test code by using relative paths, and setting
the working when running the test. This also avoids the
need to internationalize the test code.
For RunCMake.GeneratorExpression, use a UTF-8 encoding in
file(STRINGS) to retrieve the compiled absolute path correctly.
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.
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.
Set the minimum required version of CMake high enough to avoid the
warning for CMAKE_LEGACY_CYGWIN_WIN32. The warning appears on stderr
and breaks the expected output matching.
It should be possible for example to do this:
"$<AND:${FOO},$<BOOL:${TGT}>,$<BOOL:$<TARGET_PROPERTY:${TGT},PROP>"
such that it works simliarly to the C code:
if (foo && tgt && tgt->prop())
{
}
The example of generator expression code is a little bit contrived as
it could be written other ways with the same functionality. Nevertheless,
as these cases already work and are intentional, test for them.
Otherwise the comma is treated as plain text by ParseContent.
$<STREQUAL:,> should be valid and true.
$<STREQUAL:,something> should be valid and false.
$<STREQUAL:,,> should be non-valid as it is 3 parameters.
$<STREQUAL:something,,> should be non-valid as it is 3 parameters.
Additionally, this allows reporting the correct error for other
expressions. For example $<TARGET_PROPERTY:,> should be invalid
because it has an empty target and empty property. It shouldn't
attempt to read the property ',' on the 'implicit this' target.
The expressions may be parsed and then cached and evaluated multiple
times. They are evaluated lazily so that literals such as ',' can be
treated as universal parameter separators, and can be processed from
results without appearing literally, and without interfering with the
parsing/evaluation of the entire expression.
This expression evaluates to '1' or '0' to indicate whether the build
configuration for which the expression is evaluated matches tha named
configuration. In combination with the "$<0:...>" and "$<1:...>"
expressions this allows per-configuration content to be generated.
Add generator expressions that combine and use boolean test results:
$<0:...> = empty string (ignores "...")
$<1:...> = content of "..."
$<AND:?[,?]...> = '1' if all '?' are '1', else '0'
$<OR:?[,?]...> = '0' if all '?' are '0', else '1'
$<NOT:?> = '0' if '?' is '1', else '1'
These will be useful to evaluate (future) boolean query expressions and
condition content on the results. Include tests and documentation.