mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-04 13:19:51 -05:00
ENH: Enforce global target name uniqueness.
- Error if imported target is involved in conflict
- Error for non-imported target conflict unless
CMAKE_BACKWARDS_COMPATIBILITY <= 2.4
- Include OUTPUT_NAME property in error message
- Update add_executable and add_library command documentation
This commit is contained in:
@@ -109,12 +109,11 @@ bool cmAddLibraryCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for an existing target with this name.
|
||||
cmTarget* existing = this->Makefile->FindTargetToUse(libName.c_str());
|
||||
// Handle imported target creation.
|
||||
if(importTarget)
|
||||
{
|
||||
// Make sure the target does not already exist.
|
||||
if(existing)
|
||||
if(this->Makefile->FindTargetToUse(libName.c_str()))
|
||||
{
|
||||
cmOStringStream e;
|
||||
e << "cannot create imported target \"" << libName
|
||||
@@ -127,20 +126,13 @@ bool cmAddLibraryCommand
|
||||
this->Makefile->AddImportedTarget(libName.c_str(), type);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
// Enforce name uniqueness.
|
||||
std::string msg;
|
||||
if(!this->Makefile->EnforceUniqueName(libName, msg))
|
||||
{
|
||||
// Make sure the target does not conflict with an imported target.
|
||||
// This should really enforce global name uniqueness for targets
|
||||
// built within the project too, but that may break compatiblity
|
||||
// with projects in which it was accidentally working.
|
||||
if(existing && existing->IsImported())
|
||||
{
|
||||
cmOStringStream e;
|
||||
e << "cannot create target \"" << libName
|
||||
<< "\" because an imported target with the same name already exists.";
|
||||
this->SetError(e.str().c_str());
|
||||
return false;
|
||||
}
|
||||
this->SetError(msg.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (s == args.end())
|
||||
|
||||
Reference in New Issue
Block a user