Add the TARGET_NAME generator expression.
It will be used as a preprocessing marker.
This commit is contained in:
parent
77475fe61d
commit
b0c8f73eb6
@ -26,6 +26,10 @@
|
|||||||
"strings which contain a '>' for example.\n" \
|
"strings which contain a '>' for example.\n" \
|
||||||
" $<COMMA> = A literal ','. Used to compare " \
|
" $<COMMA> = A literal ','. Used to compare " \
|
||||||
"strings which contain a ',' for example.\n" \
|
"strings which contain a ',' for example.\n" \
|
||||||
|
" $<TARGET_NAME:...> = Marks ... as being the name of a " \
|
||||||
|
"target. This is required if exporting targets to multiple " \
|
||||||
|
"dependent export sets. The '...' must be a literal name of a " \
|
||||||
|
"target- it may not contain generator expressions.\n" \
|
||||||
" $<INSTALL_INTERFACE:...> = content of \"...\" when the property " \
|
" $<INSTALL_INTERFACE:...> = content of \"...\" when the property " \
|
||||||
"is exported using install(EXPORT), and empty otherwise.\n" \
|
"is exported using install(EXPORT), and empty otherwise.\n" \
|
||||||
" $<BUILD_INTERFACE:...> = content of \"...\" when the property " \
|
" $<BUILD_INTERFACE:...> = content of \"...\" when the property " \
|
||||||
|
@ -376,6 +376,28 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
|||||||
}
|
}
|
||||||
} targetPropertyNode;
|
} targetPropertyNode;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
static const struct TargetNameNode : public cmGeneratorExpressionNode
|
||||||
|
{
|
||||||
|
TargetNameNode() {}
|
||||||
|
|
||||||
|
virtual bool GeneratesContent() const { return true; }
|
||||||
|
|
||||||
|
virtual bool AcceptsSingleArbitraryContentParameter() const { return true; }
|
||||||
|
virtual bool RequiresLiteralInput() const { return true; }
|
||||||
|
|
||||||
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
||||||
|
cmGeneratorExpressionContext *,
|
||||||
|
const GeneratorExpressionContent *,
|
||||||
|
cmGeneratorExpressionDAGChecker *) const
|
||||||
|
{
|
||||||
|
return parameters.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int NumExpectedParameters() const { return 1; }
|
||||||
|
|
||||||
|
} targetNameNode;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
template<bool linker, bool soname>
|
template<bool linker, bool soname>
|
||||||
struct TargetFilesystemArtifactResultCreator
|
struct TargetFilesystemArtifactResultCreator
|
||||||
@ -601,6 +623,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
|
|||||||
return &commaNode;
|
return &commaNode;
|
||||||
else if (identifier == "TARGET_PROPERTY")
|
else if (identifier == "TARGET_PROPERTY")
|
||||||
return &targetPropertyNode;
|
return &targetPropertyNode;
|
||||||
|
else if (identifier == "TARGET_NAME")
|
||||||
|
return &targetNameNode;
|
||||||
else if (identifier == "BUILD_INTERFACE")
|
else if (identifier == "BUILD_INTERFACE")
|
||||||
return &buildInterfaceNode;
|
return &buildInterfaceNode;
|
||||||
else if (identifier == "INSTALL_INTERFACE")
|
else if (identifier == "INSTALL_INTERFACE")
|
||||||
|
@ -87,6 +87,8 @@ add_custom_target(check-part2 ALL
|
|||||||
-Dtest_incomplete_21=$<BOOL:something$<ANGLE-R>
|
-Dtest_incomplete_21=$<BOOL:something$<ANGLE-R>
|
||||||
-Dtest_build_interface=$<BUILD_INTERFACE:build>
|
-Dtest_build_interface=$<BUILD_INTERFACE:build>
|
||||||
-Dtest_install_interface=$<INSTALL_INTERFACE:install>
|
-Dtest_install_interface=$<INSTALL_INTERFACE:install>
|
||||||
|
-Dtest_target_name_1=$<TARGET_NAME:tgt,ok>
|
||||||
|
-Dtest_target_name_2=$<TARGET_NAME:tgt:ok>
|
||||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 2)"
|
COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 2)"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
|
@ -24,3 +24,5 @@ check(test_incomplete_20 "$<CONFIGURATION>")
|
|||||||
check(test_incomplete_21 "$<BOOL:something>")
|
check(test_incomplete_21 "$<BOOL:something>")
|
||||||
check(test_build_interface "build")
|
check(test_build_interface "build")
|
||||||
check(test_install_interface "")
|
check(test_install_interface "")
|
||||||
|
check(test_target_name_1 "tgt,ok")
|
||||||
|
check(test_target_name_2 "tgt:ok")
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
1
|
@ -0,0 +1,8 @@
|
|||||||
|
CMake Error at BadTargetName.cmake:1 \(add_custom_target\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<TARGET_NAME:\$<1:tgt>>
|
||||||
|
|
||||||
|
\$<TARGET_NAME> expression requires literal input.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)$
|
3
Tests/RunCMake/GeneratorExpression/BadTargetName.cmake
Normal file
3
Tests/RunCMake/GeneratorExpression/BadTargetName.cmake
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
add_custom_target(check ALL COMMAND check
|
||||||
|
$<TARGET_NAME:$<1:tgt>>
|
||||||
|
VERBATIM)
|
@ -6,3 +6,4 @@ run_cmake(BadAND)
|
|||||||
run_cmake(BadNOT)
|
run_cmake(BadNOT)
|
||||||
run_cmake(BadStrEqual)
|
run_cmake(BadStrEqual)
|
||||||
run_cmake(BadZero)
|
run_cmake(BadZero)
|
||||||
|
run_cmake(BadTargetName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user