summaryrefslogtreecommitdiffstats
path: root/Source/cmAddLibraryCommand.cxx
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2013-11-16 10:07:24 (GMT)
committerBrad King <brad.king@kitware.com>2013-11-19 14:44:22 (GMT)
commit3900fcf4a8eee24141e2d562c1b6b796b456c838 (patch)
tree5f0ffc818922b71848c91bb3fa29bcde63cacc93 /Source/cmAddLibraryCommand.cxx
parent958367e10cee44d2dbce72f9393168746099ebd1 (diff)
downloadCMake-3900fcf4a8eee24141e2d562c1b6b796b456c838.zip
CMake-3900fcf4a8eee24141e2d562c1b6b796b456c838.tar.gz
CMake-3900fcf4a8eee24141e2d562c1b6b796b456c838.tar.bz2
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 e9c5d6b..0f98f35 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());