From 3900fcf4a8eee24141e2d562c1b6b796b456c838 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Sat, 16 Nov 2013 11:07:24 +0100 Subject: 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. --- Source/cmAddLibraryCommand.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Source/cmAddLibraryCommand.cxx') 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()); -- cgit v1.2.1