summaryrefslogtreecommitdiffstats
path: root/Source/cmAddLibraryCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmAddLibraryCommand.cxx')
-rw-r--r--Source/cmAddLibraryCommand.cxx69
1 files changed, 36 insertions, 33 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index 009b1ca..cdc9f2a 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -53,7 +53,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting STATIC type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -66,7 +66,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting SHARED type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -79,7 +79,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting MODULE type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -92,7 +92,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting OBJECT type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -105,7 +105,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting UNKNOWN type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -118,7 +118,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting ALIAS type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -130,21 +130,21 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting/multiple types.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
if (isAlias)
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting ALIAS type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
if (excludeFromAll)
{
cmOStringStream e;
e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -157,7 +157,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -177,7 +177,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "GLOBAL option may only be used with IMPORTED libraries.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
else
@@ -192,14 +192,14 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library requires no source arguments.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
if (importGlobal && !importTarget)
{
cmOStringStream e;
e << "INTERFACE library specified as GLOBAL, but not as IMPORTED.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -214,11 +214,17 @@ bool cmAddLibraryCommand
if (!nameOk)
{
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ cmOStringStream e;
bool issueMessage = false;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
{
case cmPolicies::WARN:
- issueMessage = type != cmTarget::INTERFACE_LIBRARY;
+ if(type != cmTarget::INTERFACE_LIBRARY)
+ {
+ e << (this->Makefile->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n";
+ issueMessage = true;
+ }
case cmPolicies::OLD:
break;
case cmPolicies::NEW:
@@ -229,14 +235,11 @@ bool cmAddLibraryCommand
}
if (issueMessage)
{
- cmOStringStream e;
- e << (this->Makefile->GetPolicies()
- ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n";
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());
+ this->Makefile->IssueMessage(messageType, e.str());
if (messageType == cmake::FATAL_ERROR)
{
@@ -247,9 +250,9 @@ bool cmAddLibraryCommand
if (isAlias)
{
- if(!cmGeneratorExpression::IsValidTargetName(libName.c_str()))
+ if(!cmGeneratorExpression::IsValidTargetName(libName))
{
- this->SetError(("Invalid name for ALIAS: " + libName).c_str());
+ this->SetError("Invalid name for ALIAS: " + libName);
return false;
}
if(excludeFromAll)
@@ -266,7 +269,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "ALIAS requires exactly one target argument.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -276,7 +279,7 @@ bool cmAddLibraryCommand
cmOStringStream e;
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
cmTarget *aliasedTarget =
@@ -287,7 +290,7 @@ bool cmAddLibraryCommand
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" does not already "
"exist.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
cmTarget::TargetType aliasedType = aliasedTarget->GetType();
@@ -300,7 +303,7 @@ bool cmAddLibraryCommand
cmOStringStream e;
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" is not a library.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
if(aliasedTarget->IsImported())
@@ -308,10 +311,10 @@ bool cmAddLibraryCommand
cmOStringStream e;
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" is IMPORTED.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
- this->Makefile->AddAlias(libName.c_str(), aliasedTarget);
+ this->Makefile->AddAlias(libName, aliasedTarget);
return true;
}
@@ -364,7 +367,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "Invalid name for IMPORTED INTERFACE library target: " << libName;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -375,12 +378,12 @@ bool cmAddLibraryCommand
cmOStringStream e;
e << "cannot create imported target \"" << libName
<< "\" because another target with the same name already exists.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
// Create the imported target.
- this->Makefile->AddImportedTarget(libName.c_str(), type, importGlobal);
+ this->Makefile->AddImportedTarget(libName, type, importGlobal);
return true;
}
@@ -399,7 +402,7 @@ bool cmAddLibraryCommand
std::string msg;
if(!this->Makefile->EnforceUniqueName(libName, msg))
{
- this->SetError(msg.c_str());
+ this->SetError(msg);
return false;
}
}
@@ -413,11 +416,11 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "Invalid name for INTERFACE library target: " << libName;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
- this->Makefile->AddLibrary(libName.c_str(),
+ this->Makefile->AddLibrary(libName,
type,
srclists,
excludeFromAll);
@@ -439,7 +442,7 @@ bool cmAddLibraryCommand
++s;
}
- this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll);
+ this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll);
return true;
}