summaryrefslogtreecommitdiff
path: root/Source/cmAddLibraryCommand.cxx
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2013-11-16 11:07:24 +0100
committerBrad King <brad.king@kitware.com>2013-11-19 09:44:22 -0500
commit3900fcf4a8eee24141e2d562c1b6b796b456c838 (patch)
tree5f0ffc818922b71848c91bb3fa29bcde63cacc93 /Source/cmAddLibraryCommand.cxx
parent958367e10cee44d2dbce72f9393168746099ebd1 (diff)
downloadcmake-3900fcf4a8eee24141e2d562c1b6b796b456c838.tar.gz
CMP0037: Extend policy to reserved names and custom targets
Teach add_custom_target to check the policy too. Extend the policy to disallow reserved target names that we use for builtin targets like "all". Extend the RunCMake.CMP0037 test to cover these cases.
Diffstat (limited to 'Source/cmAddLibraryCommand.cxx')
-rw-r--r--Source/cmAddLibraryCommand.cxx7
1 files changed, 5 insertions, 2 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index e9c5d6b766..0f98f352c4 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -109,7 +109,9 @@ bool cmAddLibraryCommand
}
}
- bool nameOk = cmGeneratorExpression::IsValidTargetName(libName);
+ bool nameOk = cmGeneratorExpression::IsValidTargetName(libName) &&
+ !cmGlobalGenerator::IsReservedTarget(libName);
+
if (nameOk && !importTarget && !isAlias)
{
nameOk = libName.find(":") == std::string::npos;
@@ -135,7 +137,8 @@ bool cmAddLibraryCommand
cmOStringStream e;
e << (this->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0037)) << "\n";
- e << "The target name \"" << libName << "\" is not valid for certain "
+ e << "The target name \"" << libName <<
+ "\" is reserved or not valid for certain "
"CMake features, such as generator expressions, and may result "
"in undefined behavior.";
this->Makefile->IssueMessage(messageType, e.str().c_str());