An update will be applied January 25th, between 12PM and 1:00PM EST (UTC -5:00). The site may be slow during that time.

Commit fabf1fba authored by Ben Boeckel's avatar Ben Boeckel Committed by Brad King
Browse files

stringapi: Use strings in target name

parent a6ae2ea7
......@@ -130,7 +130,8 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
std::string buildCommand
= this->GlobalGenerator->
GenerateCMakeBuildCommand(cmakeBuildTarget, cmakeBuildConfiguration,
GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "",
cmakeBuildConfiguration,
cmakeBuildAdditionalFlags, true);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"SetMakeCommand:"
......
......@@ -44,7 +44,7 @@ bool cmBuildCommand
// Parse remaining arguments.
const char* configuration = 0;
const char* project_name = 0;
const char* target = 0;
std::string target;
enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget };
Doing doing = DoingNone;
for(unsigned int i=1; i < args.size(); ++i)
......@@ -74,7 +74,7 @@ bool cmBuildCommand
else if(doing == DoingTarget)
{
doing = DoingNone;
target = args[i].c_str();
target = args[i];
}
else
{
......@@ -136,7 +136,7 @@ bool cmBuildCommand
}
std::string makecommand = this->Makefile->GetLocalGenerator()
->GetGlobalGenerator()->GenerateCMakeBuildCommand(0, configType.c_str(),
->GetGlobalGenerator()->GenerateCMakeBuildCommand("", configType.c_str(),
0, true);
if(cacheValue)
......
......@@ -254,7 +254,8 @@ cmComputeLinkDepends::Compute()
"---------------------------------------"
"---------------------------------------\n");
fprintf(stderr, "Link dependency analysis for target %s, config %s\n",
this->Target->GetName(), this->Config?this->Config:"noconfig");
this->Target->GetName().c_str(),
this->Config?this->Config:"noconfig");
this->DisplayConstraintGraph();
}
......@@ -620,7 +621,7 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index,
//----------------------------------------------------------------------------
cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index,
const char* name)
const std::string& name)
{
// Look for a target in the scope of the depender.
cmMakefile* mf = this->Makefile;
......@@ -968,14 +969,14 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
//----------------------------------------------------------------------------
void cmComputeLinkDepends::DisplayFinalEntries()
{
fprintf(stderr, "target [%s] links to:\n", this->Target->GetName());
fprintf(stderr, "target [%s] links to:\n", this->Target->GetName().c_str());
for(std::vector<LinkEntry>::const_iterator lei =
this->FinalLinkEntries.begin();
lei != this->FinalLinkEntries.end(); ++lei)
{
if(lei->Target)
{
fprintf(stderr, " target [%s]\n", lei->Target->GetName());
fprintf(stderr, " target [%s]\n", lei->Target->GetName().c_str());
}
else
{
......
......@@ -83,7 +83,8 @@ private:
void AddDirectLinkEntries();
void AddLinkEntries(int depender_index,
std::vector<std::string> const& libs);
cmTarget const* FindTargetToLink(int depender_index, const char* name);
cmTarget const* FindTargetToLink(int depender_index,
const std::string& name);
// One entry for each unique item.
std::vector<LinkEntry> EntryList;
......
......@@ -500,7 +500,7 @@ bool cmComputeLinkInformation::Compute()
{
cmSystemTools::
Error("CMake can not determine linker language for target: ",
this->Target->GetName());
this->Target->GetName().c_str());
return false;
}
......
......@@ -298,7 +298,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
//----------------------------------------------------------------------------
void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
const char* dependee_name,
const std::string& dependee_name,
bool linking,
std::set<cmStdString> &emitted)
{
......@@ -333,7 +333,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
//----------------------------------------------------------------------------
void cmComputeTargetDepends::AddTargetDepend(int depender_index,
const char* dependee_name,
const std::string& dependee_name,
bool linking)
{
// Get the depender.
......@@ -434,22 +434,23 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
//----------------------------------------------------------------------------
void
cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name)
cmComputeTargetDepends::DisplayGraph(Graph const& graph,
const std::string& name)
{
fprintf(stderr, "The %s target dependency graph is:\n", name);
fprintf(stderr, "The %s target dependency graph is:\n", name.c_str());
int n = static_cast<int>(graph.size());
for(int depender_index = 0; depender_index < n; ++depender_index)
{
EdgeList const& nl = graph[depender_index];
cmTarget const* depender = this->Targets[depender_index];
fprintf(stderr, "target %d is [%s]\n",
depender_index, depender->GetName());
depender_index, depender->GetName().c_str());
for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{
int dependee_index = *ni;
cmTarget const* dependee = this->Targets[dependee_index];
fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index,
dependee->GetName(), ni->IsStrong()? "strong" : "weak");
dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak");
}
}
fprintf(stderr, "\n");
......@@ -471,7 +472,7 @@ cmComputeTargetDepends
{
int i = *ni;
fprintf(stderr, " contains target %d [%s]\n",
i, this->Targets[i]->GetName());
i, this->Targets[i]->GetName().c_str());
}
}
fprintf(stderr, "\n");
......
......@@ -45,12 +45,14 @@ private:
void CollectTargets();
void CollectDepends();
void CollectTargetDepends(int depender_index);
void AddTargetDepend(int depender_index, const char* dependee_name,
void AddTargetDepend(int depender_index,
const std::string& dependee_name,
bool linking);
void AddTargetDepend(int depender_index, cmTarget const* dependee,
bool linking);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
void AddInterfaceDepends(int depender_index, const char* dependee_name,
void AddInterfaceDepends(int depender_index,
const std::string& dependee_name,
bool linking, std::set<cmStdString> &emitted);
void AddInterfaceDepends(int depender_index, cmTarget const* dependee,
const char *config,
......@@ -71,7 +73,7 @@ private:
typedef cmGraphAdjacencyList Graph;
Graph InitialGraph;
Graph FinalGraph;
void DisplayGraph(Graph const& graph, const char* name);
void DisplayGraph(Graph const& graph, const std::string& name);
// Deal with connected components.
void DisplayComponents(cmComputeComponentGraph const& ccg);
......
......@@ -28,7 +28,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
const char* sourceDirectory = argv[2].c_str();
const char* projectName = 0;
const char* targetName = 0;
std::string targetName;
std::vector<std::string> cmakeFlags;
std::vector<std::string> compileDefs;
std::string outputVariable;
......@@ -450,7 +450,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
this->BinaryDirectory.c_str());
/* Create the actual executable. */
fprintf(fout, "add_executable(%s", targetName);
fprintf(fout, "add_executable(%s", targetName.c_str());
for(std::vector<std::string>::iterator si = sources.begin();
si != sources.end(); ++si)
{
......@@ -466,12 +466,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
if (useOldLinkLibs)
{
fprintf(fout,
"target_link_libraries(%s ${LINK_LIBRARIES})\n",targetName);
"target_link_libraries(%s ${LINK_LIBRARIES})\n",
targetName.c_str());
}
else
{
fprintf(fout, "target_link_libraries(%s %s)\n",
targetName,
targetName.c_str(),
libsToLink.c_str());
}
fclose(fout);
......@@ -610,7 +611,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
}
}
void cmCoreTryCompile::FindOutputFile(const char* targetName)
void cmCoreTryCompile::FindOutputFile(const std::string& targetName)
{
this->FindErrorMessage = "";
this->OutputFile = "";
......
......@@ -44,7 +44,7 @@ public:
TryCompileCode. The result is stored in OutputFile. If nothing is found,
the error message is stored in FindErrorMessage.
*/
void FindOutputFile(const char* targetName);
void FindOutputFile(const std::string& targetName);
cmTypeMacro(cmCoreTryCompile, cmCommand);
......
......@@ -537,7 +537,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
// Generate the xml code for one target.
void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
const char* targetName,
const std::string& targetName,
cmTarget* target,
const char* make,
const cmMakefile* makefile,
......@@ -757,7 +757,8 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target)
// Create the command line for building the given target using the selected
// make
std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
const std::string& make, const char* makefile, const char* target)
const std::string& make, const char* makefile,
const std::string& target)
{
std::string command = make;
if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)
......
......@@ -49,9 +49,9 @@ private:
std::string GetCBCompilerId(const cmMakefile* mf);
int GetCBTargetType(cmTarget* target);
std::string BuildMakeCommand(const std::string& make, const char* makefile,
const char* target);
const std::string& target);
void AppendTarget(cmGeneratedFileStream& fout,
const char* targetName,
const std::string& targetName,
cmTarget* target,
const char* make,
const cmMakefile* makefile,
......
......@@ -223,7 +223,7 @@ void cmExtraSublimeTextGenerator::
void cmExtraSublimeTextGenerator::
AppendTarget(cmGeneratedFileStream& fout,
const char* targetName,
const std::string& targetName,
cmLocalGenerator* lg,
cmTarget* target,
const char* make,
......@@ -315,7 +315,8 @@ void cmExtraSublimeTextGenerator::
// Create the command line for building the given target using the selected
// make
std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
const std::string& make, const char* makefile, const char* target)
const std::string& make, const char* makefile,
const std::string& target)
{
std::string command = "\"";
command += make + "\"";
......
......@@ -60,12 +60,12 @@ private:
* specified target.
*/
std::string BuildMakeCommand(const std::string& make, const char* makefile,
const char* target);
const std::string& target);
/** Appends the specified target to the generated project file as a Sublime
* Text build system.
*/
void AppendTarget(cmGeneratedFileStream& fout,
const char* targetName,
const std::string& targetName,
cmLocalGenerator* lg,
cmTarget* target,
const char* make,
......
......@@ -228,7 +228,7 @@ int cmGeneratorTarget::GetType() const
}
//----------------------------------------------------------------------------
const char *cmGeneratorTarget::GetName() const
std::string cmGeneratorTarget::GetName() const
{
return this->Target->GetName();
}
......@@ -988,7 +988,7 @@ void cmGeneratorTarget::GenerateTargetManifest(const char* config) const
bool cmStrictTargetComparison::operator()(cmTarget const* t1,
cmTarget const* t2) const
{
int nameResult = strcmp(t1->GetName(), t2->GetName());
int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str());
if (nameResult == 0)
{
return strcmp(t1->GetMakefile()->GetStartOutputDirectory(),
......
......@@ -27,7 +27,7 @@ public:
cmGeneratorTarget(cmTarget*);
int GetType() const;
const char *GetName() const;
std::string GetName() const;
const char *GetProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
void GetSourceFiles(std::vector<cmSourceFile*>& files) const;
......
......@@ -295,7 +295,7 @@ bool cmGetPropertyCommand::HandleTargetMode()
if(cmTarget* target =
this->Makefile->FindTargetToUse(this->Name))
{
return this->StoreResult(target->GetName());
return this->StoreResult(target->GetName().c_str());
}
}
return this->StoreResult((this->Variable + "-NOTFOUND").c_str());
......
......@@ -1616,7 +1616,7 @@ void cmGlobalGenerator::CheckLocalGenerators()
int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
const char *projectName,
const char *target, bool fast,
const std::string& target, bool fast,
std::string *output, cmMakefile *mf)
{
// if this is not set, then this is a first time configure
......@@ -1640,7 +1640,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
}
std::string newTarget;
if (target && strlen(target))
if (!target.empty())
{
newTarget += target;
#if 0
......@@ -1664,7 +1664,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
void cmGlobalGenerator::GenerateBuildCommand(
std::vector<std::string>& makeCommand, const char*, const char*, const char*,
const char*, const char*, bool, std::vector<std::string> const&)
const std::string&, const char*, bool, std::vector<std::string> const&)
{
makeCommand.push_back(
"cmGlobalGenerator::GenerateBuildCommand not implemented");
......@@ -1672,7 +1672,7 @@ void cmGlobalGenerator::GenerateBuildCommand(
int cmGlobalGenerator::Build(
const char *, const char *bindir,
const char *projectName, const char *target,
const char *projectName, const std::string& target,
std::string *output,
const char *makeCommandCSTR,
const char *config,
......@@ -1787,7 +1787,7 @@ int cmGlobalGenerator::Build(
//----------------------------------------------------------------------------
std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
const char* target, const char* config, const char* native,
const std::string& target, const char* config, const char* native,
bool ignoreErrors)
{
std::string makeCommand = cmSystemTools::GetCMakeCommand();
......@@ -1799,7 +1799,7 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
makeCommand += config;
makeCommand += "\"";
}
if(target && *target)
if(!target.empty())
{
makeCommand += " --target \"";
makeCommand += target;
......@@ -2041,7 +2041,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
///! Find a local generator by its startdirectory
cmLocalGenerator*
cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const
cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const
{
for(std::vector<cmLocalGenerator*>::const_iterator it =
this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it)
......@@ -2056,20 +2056,20 @@ cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const
}
//----------------------------------------------------------------------------
void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt)
void cmGlobalGenerator::AddAlias(const std::string& name, cmTarget *tgt)
{
this->AliasTargets[name] = tgt;
}
//----------------------------------------------------------------------------
bool cmGlobalGenerator::IsAlias(const char *name) const
bool cmGlobalGenerator::IsAlias(const std::string& name) const
{
return this->AliasTargets.find(name) != this->AliasTargets.end();
}
//----------------------------------------------------------------------------
cmTarget*
cmGlobalGenerator::FindTarget(const char* project, const char* name,
cmGlobalGenerator::FindTarget(const char* project, const std::string& name,
bool excludeAliases) const
{
// if project specific
......@@ -2481,7 +2481,7 @@ void cmGlobalGenerator::EnableMinGWLanguage(cmMakefile *mf)
//----------------------------------------------------------------------------
cmTarget cmGlobalGenerator::CreateGlobalTarget(
const char* name, const char* message,
const std::string& name, const char* message,
const cmCustomCommandLines* commandLines,
std::vector<std::string> depends,
const char* workingDirectory)
......@@ -2672,7 +2672,7 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets,
bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const
{
return (target->GetType() == cmTarget::GLOBAL_TARGET ||
strcmp(target->GetName(), this->GetAllTargetName()) == 0);
target->GetName() == this->GetAllTargetName());
}
//----------------------------------------------------------------------------
......
......@@ -106,7 +106,8 @@ public:
* loaded commands, not as part of the usual build process.
*/
virtual int TryCompile(const char *srcdir, const char *bindir,
const char *projectName, const char *targetName,
const char *projectName,
const std::string& targetName,
bool fast, std::string *output, cmMakefile* mf);
......@@ -117,7 +118,7 @@ public:
* done first.
*/
int Build(const char *srcdir, const char *bindir,
const char *projectName, const char *targetName,
const char *projectName, const std::string& targetName,
std::string *output,
const char *makeProgram, const char *config,
bool clean, bool fast,
......@@ -130,12 +131,12 @@ public:
std::vector<std::string>& makeCommand,
const char* makeProgram,
const char *projectName, const char *projectDir,
const char *targetName, const char* config, bool fast,
const std::string& targetName, const char* config, bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>()
);
/** Generate a "cmake --build" call for a given target and config. */
std::string GenerateCMakeBuildCommand(const char* target,
std::string GenerateCMakeBuildCommand(const std::string& target,
const char* config,
const char* native,
bool ignoreErrors);
......@@ -210,11 +211,11 @@ public:
virtual void FindMakeProgram(cmMakefile*);
///! Find a target by name by searching the local generators.
cmTarget* FindTarget(const char* project, const char* name,
cmTarget* FindTarget(const char* project, const std::string& name,
bool excludeAliases = false) const;
void AddAlias(const char *name, cmTarget *tgt);
bool IsAlias(const char *name) const;
void AddAlias(const std::string& name, cmTarget *tgt);
bool IsAlias(const std::string& name) const;
/** Determine if a name resolves to a framework on disk or a built target
that is a framework. */
......@@ -224,7 +225,7 @@ public:
target in the project */
bool IsDependedOn(const char* project, cmTarget const* target);
///! Find a local generator by its startdirectory
cmLocalGenerator* FindLocalGenerator(const char* start_dir) const;
cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const;
/** Append the subdirectory for the given configuration. If anything is
appended the given prefix and suffix will be appended around it, which
......@@ -355,7 +356,7 @@ protected:
bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const;
void FillLocalGeneratorToTargetMap();
void CreateDefaultGlobalTargets(cmTargets* targets);
cmTarget CreateGlobalTarget(const char* name, const char* message,
cmTarget CreateGlobalTarget(const std::string& name, const char* message,
const cmCustomCommandLines* commandLines,
std::vector<std::string> depends, const char* workingDir);
......
......@@ -554,7 +554,7 @@ void cmGlobalNinjaGenerator
const char* makeProgram,
const char* /*projectName*/,
const char* /*projectDir*/,
const char* targetName,
const std::string& targetName,
const char* /*config*/,
bool /*fast*/,
std::vector<std::string> const& makeOptions)
......@@ -565,9 +565,9 @@ void cmGlobalNinjaGenerator
makeCommand.insert(makeCommand.end(),
makeOptions.begin(), makeOptions.end());
if(targetName && *targetName)
if(!targetName.empty())
{
if(strcmp(targetName, "clean") == 0)
if(targetName == "clean")
{
makeCommand.push_back("-t");
makeCommand.push_back("clean");
......
......@@ -196,7 +196,7 @@ public:
const char* makeProgram,
const char* projectName,
const char* projectDir,
const char* targetName,
const std::string& targetName,
const char* config,
bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment