stringapi: Use strings in target name

This commit is contained in:
Ben Boeckel 2014-02-06 17:31:47 -05:00 committed by Brad King
parent a6ae2ea72b
commit fabf1fbabb
58 changed files with 287 additions and 274 deletions

View File

@ -130,7 +130,8 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
std::string buildCommand std::string buildCommand
= this->GlobalGenerator-> = this->GlobalGenerator->
GenerateCMakeBuildCommand(cmakeBuildTarget, cmakeBuildConfiguration, GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "",
cmakeBuildConfiguration,
cmakeBuildAdditionalFlags, true); cmakeBuildAdditionalFlags, true);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"SetMakeCommand:" "SetMakeCommand:"

View File

@ -44,7 +44,7 @@ bool cmBuildCommand
// Parse remaining arguments. // Parse remaining arguments.
const char* configuration = 0; const char* configuration = 0;
const char* project_name = 0; const char* project_name = 0;
const char* target = 0; std::string target;
enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget }; enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget };
Doing doing = DoingNone; Doing doing = DoingNone;
for(unsigned int i=1; i < args.size(); ++i) for(unsigned int i=1; i < args.size(); ++i)
@ -74,7 +74,7 @@ bool cmBuildCommand
else if(doing == DoingTarget) else if(doing == DoingTarget)
{ {
doing = DoingNone; doing = DoingNone;
target = args[i].c_str(); target = args[i];
} }
else else
{ {
@ -136,7 +136,7 @@ bool cmBuildCommand
} }
std::string makecommand = this->Makefile->GetLocalGenerator() std::string makecommand = this->Makefile->GetLocalGenerator()
->GetGlobalGenerator()->GenerateCMakeBuildCommand(0, configType.c_str(), ->GetGlobalGenerator()->GenerateCMakeBuildCommand("", configType.c_str(),
0, true); 0, true);
if(cacheValue) if(cacheValue)

View File

@ -254,7 +254,8 @@ cmComputeLinkDepends::Compute()
"---------------------------------------" "---------------------------------------"
"---------------------------------------\n"); "---------------------------------------\n");
fprintf(stderr, "Link dependency analysis for target %s, config %s\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(); this->DisplayConstraintGraph();
} }
@ -620,7 +621,7 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget const* cmComputeLinkDepends::FindTargetToLink(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. // Look for a target in the scope of the depender.
cmMakefile* mf = this->Makefile; cmMakefile* mf = this->Makefile;
@ -968,14 +969,14 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmComputeLinkDepends::DisplayFinalEntries() 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 = for(std::vector<LinkEntry>::const_iterator lei =
this->FinalLinkEntries.begin(); this->FinalLinkEntries.begin();
lei != this->FinalLinkEntries.end(); ++lei) lei != this->FinalLinkEntries.end(); ++lei)
{ {
if(lei->Target) if(lei->Target)
{ {
fprintf(stderr, " target [%s]\n", lei->Target->GetName()); fprintf(stderr, " target [%s]\n", lei->Target->GetName().c_str());
} }
else else
{ {

View File

@ -83,7 +83,8 @@ private:
void AddDirectLinkEntries(); void AddDirectLinkEntries();
void AddLinkEntries(int depender_index, void AddLinkEntries(int depender_index,
std::vector<std::string> const& libs); 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. // One entry for each unique item.
std::vector<LinkEntry> EntryList; std::vector<LinkEntry> EntryList;

View File

@ -500,7 +500,7 @@ bool cmComputeLinkInformation::Compute()
{ {
cmSystemTools:: cmSystemTools::
Error("CMake can not determine linker language for target: ", Error("CMake can not determine linker language for target: ",
this->Target->GetName()); this->Target->GetName().c_str());
return false; return false;
} }

View File

@ -298,7 +298,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
const char* dependee_name, const std::string& dependee_name,
bool linking, bool linking,
std::set<cmStdString> &emitted) std::set<cmStdString> &emitted)
{ {
@ -333,7 +333,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmComputeTargetDepends::AddTargetDepend(int depender_index, void cmComputeTargetDepends::AddTargetDepend(int depender_index,
const char* dependee_name, const std::string& dependee_name,
bool linking) bool linking)
{ {
// Get the depender. // Get the depender.
@ -434,22 +434,23 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void 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()); int n = static_cast<int>(graph.size());
for(int depender_index = 0; depender_index < n; ++depender_index) for(int depender_index = 0; depender_index < n; ++depender_index)
{ {
EdgeList const& nl = graph[depender_index]; EdgeList const& nl = graph[depender_index];
cmTarget const* depender = this->Targets[depender_index]; cmTarget const* depender = this->Targets[depender_index];
fprintf(stderr, "target %d is [%s]\n", 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) for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{ {
int dependee_index = *ni; int dependee_index = *ni;
cmTarget const* dependee = this->Targets[dependee_index]; cmTarget const* dependee = this->Targets[dependee_index];
fprintf(stderr, " depends on target %d [%s] (%s)\n", 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"); fprintf(stderr, "\n");
@ -471,7 +472,7 @@ cmComputeTargetDepends
{ {
int i = *ni; int i = *ni;
fprintf(stderr, " contains target %d [%s]\n", fprintf(stderr, " contains target %d [%s]\n",
i, this->Targets[i]->GetName()); i, this->Targets[i]->GetName().c_str());
} }
} }
fprintf(stderr, "\n"); fprintf(stderr, "\n");

View File

@ -45,12 +45,14 @@ private:
void CollectTargets(); void CollectTargets();
void CollectDepends(); void CollectDepends();
void CollectTargetDepends(int depender_index); 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); bool linking);
void AddTargetDepend(int depender_index, cmTarget const* dependee, void AddTargetDepend(int depender_index, cmTarget const* dependee,
bool linking); bool linking);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); 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); bool linking, std::set<cmStdString> &emitted);
void AddInterfaceDepends(int depender_index, cmTarget const* dependee, void AddInterfaceDepends(int depender_index, cmTarget const* dependee,
const char *config, const char *config,
@ -71,7 +73,7 @@ private:
typedef cmGraphAdjacencyList Graph; typedef cmGraphAdjacencyList Graph;
Graph InitialGraph; Graph InitialGraph;
Graph FinalGraph; Graph FinalGraph;
void DisplayGraph(Graph const& graph, const char* name); void DisplayGraph(Graph const& graph, const std::string& name);
// Deal with connected components. // Deal with connected components.
void DisplayComponents(cmComputeComponentGraph const& ccg); void DisplayComponents(cmComputeComponentGraph const& ccg);

View File

@ -28,7 +28,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
const char* sourceDirectory = argv[2].c_str(); const char* sourceDirectory = argv[2].c_str();
const char* projectName = 0; const char* projectName = 0;
const char* targetName = 0; std::string targetName;
std::vector<std::string> cmakeFlags; std::vector<std::string> cmakeFlags;
std::vector<std::string> compileDefs; std::vector<std::string> compileDefs;
std::string outputVariable; 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", fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
this->BinaryDirectory.c_str()); this->BinaryDirectory.c_str());
/* Create the actual executable. */ /* 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(); for(std::vector<std::string>::iterator si = sources.begin();
si != sources.end(); ++si) si != sources.end(); ++si)
{ {
@ -466,12 +466,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
if (useOldLinkLibs) if (useOldLinkLibs)
{ {
fprintf(fout, fprintf(fout,
"target_link_libraries(%s ${LINK_LIBRARIES})\n",targetName); "target_link_libraries(%s ${LINK_LIBRARIES})\n",
targetName.c_str());
} }
else else
{ {
fprintf(fout, "target_link_libraries(%s %s)\n", fprintf(fout, "target_link_libraries(%s %s)\n",
targetName, targetName.c_str(),
libsToLink.c_str()); libsToLink.c_str());
} }
fclose(fout); 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->FindErrorMessage = "";
this->OutputFile = ""; this->OutputFile = "";

View File

@ -44,7 +44,7 @@ public:
TryCompileCode. The result is stored in OutputFile. If nothing is found, TryCompileCode. The result is stored in OutputFile. If nothing is found,
the error message is stored in FindErrorMessage. the error message is stored in FindErrorMessage.
*/ */
void FindOutputFile(const char* targetName); void FindOutputFile(const std::string& targetName);
cmTypeMacro(cmCoreTryCompile, cmCommand); cmTypeMacro(cmCoreTryCompile, cmCommand);

View File

@ -537,7 +537,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
// Generate the xml code for one target. // Generate the xml code for one target.
void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
const char* targetName, const std::string& targetName,
cmTarget* target, cmTarget* target,
const char* make, const char* make,
const cmMakefile* makefile, const cmMakefile* makefile,
@ -757,7 +757,8 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target)
// Create the command line for building the given target using the selected // Create the command line for building the given target using the selected
// make // make
std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( 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; std::string command = make;
if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)

View File

@ -49,9 +49,9 @@ private:
std::string GetCBCompilerId(const cmMakefile* mf); std::string GetCBCompilerId(const cmMakefile* mf);
int GetCBTargetType(cmTarget* target); int GetCBTargetType(cmTarget* target);
std::string BuildMakeCommand(const std::string& make, const char* makefile, std::string BuildMakeCommand(const std::string& make, const char* makefile,
const char* target); const std::string& target);
void AppendTarget(cmGeneratedFileStream& fout, void AppendTarget(cmGeneratedFileStream& fout,
const char* targetName, const std::string& targetName,
cmTarget* target, cmTarget* target,
const char* make, const char* make,
const cmMakefile* makefile, const cmMakefile* makefile,

View File

@ -223,7 +223,7 @@ void cmExtraSublimeTextGenerator::
void cmExtraSublimeTextGenerator:: void cmExtraSublimeTextGenerator::
AppendTarget(cmGeneratedFileStream& fout, AppendTarget(cmGeneratedFileStream& fout,
const char* targetName, const std::string& targetName,
cmLocalGenerator* lg, cmLocalGenerator* lg,
cmTarget* target, cmTarget* target,
const char* make, const char* make,
@ -315,7 +315,8 @@ void cmExtraSublimeTextGenerator::
// Create the command line for building the given target using the selected // Create the command line for building the given target using the selected
// make // make
std::string cmExtraSublimeTextGenerator::BuildMakeCommand( 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 = "\""; std::string command = "\"";
command += make + "\""; command += make + "\"";

View File

@ -60,12 +60,12 @@ private:
* specified target. * specified target.
*/ */
std::string BuildMakeCommand(const std::string& make, const char* makefile, 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 /** Appends the specified target to the generated project file as a Sublime
* Text build system. * Text build system.
*/ */
void AppendTarget(cmGeneratedFileStream& fout, void AppendTarget(cmGeneratedFileStream& fout,
const char* targetName, const std::string& targetName,
cmLocalGenerator* lg, cmLocalGenerator* lg,
cmTarget* target, cmTarget* target,
const char* make, const char* make,

View File

@ -228,7 +228,7 @@ int cmGeneratorTarget::GetType() const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char *cmGeneratorTarget::GetName() const std::string cmGeneratorTarget::GetName() const
{ {
return this->Target->GetName(); return this->Target->GetName();
} }
@ -988,7 +988,7 @@ void cmGeneratorTarget::GenerateTargetManifest(const char* config) const
bool cmStrictTargetComparison::operator()(cmTarget const* t1, bool cmStrictTargetComparison::operator()(cmTarget const* t1,
cmTarget const* t2) const 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) if (nameResult == 0)
{ {
return strcmp(t1->GetMakefile()->GetStartOutputDirectory(), return strcmp(t1->GetMakefile()->GetStartOutputDirectory(),

View File

@ -27,7 +27,7 @@ public:
cmGeneratorTarget(cmTarget*); cmGeneratorTarget(cmTarget*);
int GetType() const; int GetType() const;
const char *GetName() const; std::string GetName() const;
const char *GetProperty(const std::string& prop) const; const char *GetProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const;
void GetSourceFiles(std::vector<cmSourceFile*>& files) const; void GetSourceFiles(std::vector<cmSourceFile*>& files) const;

View File

@ -295,7 +295,7 @@ bool cmGetPropertyCommand::HandleTargetMode()
if(cmTarget* target = if(cmTarget* target =
this->Makefile->FindTargetToUse(this->Name)) 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()); return this->StoreResult((this->Variable + "-NOTFOUND").c_str());

View File

@ -1616,7 +1616,7 @@ void cmGlobalGenerator::CheckLocalGenerators()
int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
const char *projectName, const char *projectName,
const char *target, bool fast, const std::string& target, bool fast,
std::string *output, cmMakefile *mf) std::string *output, cmMakefile *mf)
{ {
// if this is not set, then this is a first time configure // 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; std::string newTarget;
if (target && strlen(target)) if (!target.empty())
{ {
newTarget += target; newTarget += target;
#if 0 #if 0
@ -1664,7 +1664,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
void cmGlobalGenerator::GenerateBuildCommand( void cmGlobalGenerator::GenerateBuildCommand(
std::vector<std::string>& makeCommand, const char*, const char*, const char*, 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( makeCommand.push_back(
"cmGlobalGenerator::GenerateBuildCommand not implemented"); "cmGlobalGenerator::GenerateBuildCommand not implemented");
@ -1672,7 +1672,7 @@ void cmGlobalGenerator::GenerateBuildCommand(
int cmGlobalGenerator::Build( int cmGlobalGenerator::Build(
const char *, const char *bindir, const char *, const char *bindir,
const char *projectName, const char *target, const char *projectName, const std::string& target,
std::string *output, std::string *output,
const char *makeCommandCSTR, const char *makeCommandCSTR,
const char *config, const char *config,
@ -1787,7 +1787,7 @@ int cmGlobalGenerator::Build(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmGlobalGenerator::GenerateCMakeBuildCommand( 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) bool ignoreErrors)
{ {
std::string makeCommand = cmSystemTools::GetCMakeCommand(); std::string makeCommand = cmSystemTools::GetCMakeCommand();
@ -1799,7 +1799,7 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
makeCommand += config; makeCommand += config;
makeCommand += "\""; makeCommand += "\"";
} }
if(target && *target) if(!target.empty())
{ {
makeCommand += " --target \""; makeCommand += " --target \"";
makeCommand += target; makeCommand += target;
@ -2041,7 +2041,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
///! Find a local generator by its startdirectory ///! Find a local generator by its startdirectory
cmLocalGenerator* cmLocalGenerator*
cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const
{ {
for(std::vector<cmLocalGenerator*>::const_iterator it = for(std::vector<cmLocalGenerator*>::const_iterator it =
this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++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; 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(); return this->AliasTargets.find(name) != this->AliasTargets.end();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget* cmTarget*
cmGlobalGenerator::FindTarget(const char* project, const char* name, cmGlobalGenerator::FindTarget(const char* project, const std::string& name,
bool excludeAliases) const bool excludeAliases) const
{ {
// if project specific // if project specific
@ -2481,7 +2481,7 @@ void cmGlobalGenerator::EnableMinGWLanguage(cmMakefile *mf)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget cmGlobalGenerator::CreateGlobalTarget( cmTarget cmGlobalGenerator::CreateGlobalTarget(
const char* name, const char* message, const std::string& name, const char* message,
const cmCustomCommandLines* commandLines, const cmCustomCommandLines* commandLines,
std::vector<std::string> depends, std::vector<std::string> depends,
const char* workingDirectory) const char* workingDirectory)
@ -2672,7 +2672,7 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets,
bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const
{ {
return (target->GetType() == cmTarget::GLOBAL_TARGET || return (target->GetType() == cmTarget::GLOBAL_TARGET ||
strcmp(target->GetName(), this->GetAllTargetName()) == 0); target->GetName() == this->GetAllTargetName());
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -106,7 +106,8 @@ public:
* loaded commands, not as part of the usual build process. * loaded commands, not as part of the usual build process.
*/ */
virtual int TryCompile(const char *srcdir, const char *bindir, 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); bool fast, std::string *output, cmMakefile* mf);
@ -117,7 +118,7 @@ public:
* done first. * done first.
*/ */
int Build(const char *srcdir, const char *bindir, int Build(const char *srcdir, const char *bindir,
const char *projectName, const char *targetName, const char *projectName, const std::string& targetName,
std::string *output, std::string *output,
const char *makeProgram, const char *config, const char *makeProgram, const char *config,
bool clean, bool fast, bool clean, bool fast,
@ -130,12 +131,12 @@ public:
std::vector<std::string>& makeCommand, std::vector<std::string>& makeCommand,
const char* makeProgram, const char* makeProgram,
const char *projectName, const char *projectDir, 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>() std::vector<std::string> const& makeOptions = std::vector<std::string>()
); );
/** Generate a "cmake --build" call for a given target and config. */ /** 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* config,
const char* native, const char* native,
bool ignoreErrors); bool ignoreErrors);
@ -210,11 +211,11 @@ public:
virtual void FindMakeProgram(cmMakefile*); virtual void FindMakeProgram(cmMakefile*);
///! Find a target by name by searching the local generators. ///! 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; bool excludeAliases = false) const;
void AddAlias(const char *name, cmTarget *tgt); void AddAlias(const std::string& name, cmTarget *tgt);
bool IsAlias(const char *name) const; bool IsAlias(const std::string& name) const;
/** Determine if a name resolves to a framework on disk or a built target /** Determine if a name resolves to a framework on disk or a built target
that is a framework. */ that is a framework. */
@ -224,7 +225,7 @@ public:
target in the project */ target in the project */
bool IsDependedOn(const char* project, cmTarget const* target); bool IsDependedOn(const char* project, cmTarget const* target);
///! Find a local generator by its startdirectory ///! 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 /** Append the subdirectory for the given configuration. If anything is
appended the given prefix and suffix will be appended around it, which 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; bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const;
void FillLocalGeneratorToTargetMap(); void FillLocalGeneratorToTargetMap();
void CreateDefaultGlobalTargets(cmTargets* targets); void CreateDefaultGlobalTargets(cmTargets* targets);
cmTarget CreateGlobalTarget(const char* name, const char* message, cmTarget CreateGlobalTarget(const std::string& name, const char* message,
const cmCustomCommandLines* commandLines, const cmCustomCommandLines* commandLines,
std::vector<std::string> depends, const char* workingDir); std::vector<std::string> depends, const char* workingDir);

View File

@ -554,7 +554,7 @@ void cmGlobalNinjaGenerator
const char* makeProgram, const char* makeProgram,
const char* /*projectName*/, const char* /*projectName*/,
const char* /*projectDir*/, const char* /*projectDir*/,
const char* targetName, const std::string& targetName,
const char* /*config*/, const char* /*config*/,
bool /*fast*/, bool /*fast*/,
std::vector<std::string> const& makeOptions) std::vector<std::string> const& makeOptions)
@ -565,9 +565,9 @@ void cmGlobalNinjaGenerator
makeCommand.insert(makeCommand.end(), makeCommand.insert(makeCommand.end(),
makeOptions.begin(), makeOptions.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("-t");
makeCommand.push_back("clean"); makeCommand.push_back("clean");

View File

@ -196,7 +196,7 @@ public:
const char* makeProgram, const char* makeProgram,
const char* projectName, const char* projectName,
const char* projectDir, const char* projectDir,
const char* targetName, const std::string& targetName,
const char* config, const char* config,
bool fast, bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>() std::vector<std::string> const& makeOptions = std::vector<std::string>()

View File

@ -568,7 +568,7 @@ void cmGlobalUnixMakefileGenerator3
const char* makeProgram, const char* makeProgram,
const char* /*projectName*/, const char* /*projectName*/,
const char* /*projectDir*/, const char* /*projectDir*/,
const char* targetName, const std::string& targetName,
const char* /*config*/, const char* /*config*/,
bool fast, bool fast,
std::vector<std::string> const& makeOptions) std::vector<std::string> const& makeOptions)
@ -585,7 +585,7 @@ void cmGlobalUnixMakefileGenerator3
} }
makeCommand.insert(makeCommand.end(), makeCommand.insert(makeCommand.end(),
makeOptions.begin(), makeOptions.end()); makeOptions.begin(), makeOptions.end());
if ( targetName && strlen(targetName)) if (!targetName.empty())
{ {
cmLocalUnixMakefileGenerator3 *lg; cmLocalUnixMakefileGenerator3 *lg;
if (this->LocalGenerators.size()) if (this->LocalGenerators.size())
@ -649,8 +649,7 @@ cmGlobalUnixMakefileGenerator3
} }
// Don't emit the same rule twice (e.g. two targets with the same // Don't emit the same rule twice (e.g. two targets with the same
// simple name) // simple name)
if(t->second->GetName() && if(!t->second->GetName().empty() &&
strlen(t->second->GetName()) &&
emitted.insert(t->second->GetName()).second && emitted.insert(t->second->GetName()).second &&
// Handle user targets here. Global targets are handled in // Handle user targets here. Global targets are handled in
// the local generator on a per-directory basis. // the local generator on a per-directory basis.
@ -746,8 +745,7 @@ cmGlobalUnixMakefileGenerator3
{ {
continue; continue;
} }
if (t->second->GetName() if (!t->second->GetName().empty()
&& strlen(t->second->GetName())
&& ((t->second->GetType() == cmTarget::EXECUTABLE) && ((t->second->GetType() == cmTarget::EXECUTABLE)
|| (t->second->GetType() == cmTarget::STATIC_LIBRARY) || (t->second->GetType() == cmTarget::STATIC_LIBRARY)
|| (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::SHARED_LIBRARY)
@ -975,7 +973,7 @@ cmGlobalUnixMakefileGenerator3::ProgressMapCompare
::operator()(cmTarget const* l, cmTarget const* r) const ::operator()(cmTarget const* l, cmTarget const* r) const
{ {
// Order by target name. // Order by target name.
if(int c = strcmp(l->GetName(), r->GetName())) if(int c = strcmp(l->GetName().c_str(), r->GetName().c_str()))
{ {
return c < 0; return c < 0;
} }

View File

@ -112,7 +112,7 @@ public:
const char* makeProgram, const char* makeProgram,
const char* projectName, const char* projectName,
const char* projectDir, const char* projectDir,
const char* targetName, const std::string& targetName,
const char* config, const char* config,
bool fast, bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>() std::vector<std::string> const& makeOptions = std::vector<std::string>()

View File

@ -313,7 +313,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
const char* makeProgram, const char* makeProgram,
const char* projectName, const char* projectName,
const char* projectDir, const char* projectDir,
const char* targetName, const std::string& targetName,
const char* config, const char* config,
bool fast, bool fast,
std::vector<std::string> const& makeOptions) std::vector<std::string> const& makeOptions)
@ -369,25 +369,26 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
makeCommand.push_back(makeProgramSelected); makeCommand.push_back(makeProgramSelected);
std::string realTarget = targetName;
// msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
if(!targetName || strlen(targetName) == 0) if(realTarget.empty())
{ {
targetName = "ALL_BUILD"; realTarget = "ALL_BUILD";
} }
if ( targetName && strcmp(targetName, "clean") == 0 ) if ( realTarget == "clean" )
{ {
makeCommand.push_back(std::string(projectName)+".sln"); makeCommand.push_back(std::string(projectName)+".sln");
makeCommand.push_back("/t:Clean"); makeCommand.push_back("/t:Clean");
} }
else else
{ {
std::string targetProject(targetName); std::string targetProject(realTarget);
targetProject += ".vcxproj"; targetProject += ".vcxproj";
if (targetProject.find('/') == std::string::npos) if (targetProject.find('/') == std::string::npos)
{ {
// it might be in a subdir // it might be in a subdir
if (cmSlnProjectEntry const* proj = if (cmSlnProjectEntry const* proj =
slnData.GetProjectByName(targetName)) slnData.GetProjectByName(realTarget))
{ {
targetProject = proj->GetRelativePath(); targetProject = proj->GetRelativePath();
cmSystemTools::ConvertToUnixSlashes(targetProject); cmSystemTools::ConvertToUnixSlashes(targetProject);

View File

@ -37,7 +37,7 @@ public:
const char* makeProgram, const char* makeProgram,
const char* projectName, const char* projectName,
const char* projectDir, const char* projectDir,
const char* targetName, const std::string& targetName,
const char* config, const char* config,
bool fast, bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>() std::vector<std::string> const& makeOptions = std::vector<std::string>()

View File

@ -119,7 +119,7 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand(
const char* makeProgram, const char* makeProgram,
const char* projectName, const char* projectName,
const char* /*projectDir*/, const char* /*projectDir*/,
const char* targetName, const std::string& targetName,
const char* config, const char* config,
bool /*fast*/, bool /*fast*/,
std::vector<std::string> const& makeOptions std::vector<std::string> const& makeOptions
@ -134,14 +134,15 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand(
makeCommand.push_back("/MAKE"); makeCommand.push_back("/MAKE");
std::string targetArg; std::string targetArg;
bool clean = false; bool clean = false;
if ( targetName && strcmp(targetName, "clean") == 0 ) std::string realTarget = targetName;
if ( realTarget == "clean" )
{ {
clean = true; clean = true;
targetName = "ALL_BUILD"; realTarget = "ALL_BUILD";
} }
if (targetName && strlen(targetName)) if (!realTarget.empty())
{ {
targetArg += targetName; targetArg += realTarget;
} }
else else
{ {

View File

@ -57,7 +57,7 @@ public:
const char* makeProgram, const char* makeProgram,
const char* projectName, const char* projectName,
const char* projectDir, const char* projectDir,
const char* targetName, const std::string& targetName,
const char* config, const char* config,
bool fast, bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>() std::vector<std::string> const& makeOptions = std::vector<std::string>()

View File

@ -186,7 +186,7 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
const char* makeProgram, const char* makeProgram,
const char* projectName, const char* projectName,
const char* /*projectDir*/, const char* /*projectDir*/,
const char* targetName, const std::string& targetName,
const char* config, const char* config,
bool /*fast*/, bool /*fast*/,
std::vector<std::string> const& makeOptions) std::vector<std::string> const& makeOptions)
@ -208,11 +208,12 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
makeCommand.push_back(makeProgramSelected); makeCommand.push_back(makeProgramSelected);
makeCommand.push_back(std::string(projectName) + ".sln"); makeCommand.push_back(std::string(projectName) + ".sln");
std::string realTarget = targetName;
bool clean = false; bool clean = false;
if ( targetName && strcmp(targetName, "clean") == 0 ) if ( realTarget == "clean" )
{ {
clean = true; clean = true;
targetName = "ALL_BUILD"; realTarget = "ALL_BUILD";
} }
if(clean) if(clean)
{ {
@ -233,9 +234,9 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
} }
makeCommand.push_back("/project"); makeCommand.push_back("/project");
if (targetName && strlen(targetName)) if (!realTarget.empty())
{ {
makeCommand.push_back(targetName); makeCommand.push_back(realTarget);
} }
else else
{ {
@ -381,7 +382,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
std::set<std::string> allConfigurations(this->Configurations.begin(), std::set<std::string> allConfigurations(this->Configurations.begin(),
this->Configurations.end()); this->Configurations.end());
this->WriteProjectConfigurations( this->WriteProjectConfigurations(
fout, target->GetName(), target->GetType(), fout, target->GetName().c_str(), target->GetType(),
allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING")); allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING"));
} }
else else

View File

@ -65,7 +65,7 @@ public:
const char* makeProgram, const char* makeProgram,
const char* projectName, const char* projectName,
const char* projectDir, const char* projectDir,
const char* targetName, const std::string& targetName,
const char* config, const char* config,
bool fast, bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>() std::vector<std::string> const& makeOptions = std::vector<std::string>()

View File

@ -426,7 +426,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
{ {
continue; continue;
} }
std::string guid = this->GetGUID((*i)->GetName()); std::string guid = this->GetGUID((*i)->GetName().c_str());
fout << "\t\t{" << guid << "} = {" << guid << "}\n"; fout << "\t\t{" << guid << "} = {" << guid << "}\n";
} }
} }

View File

@ -870,15 +870,15 @@ cmGlobalVisualStudioGenerator::TargetCompare
::operator()(cmTarget const* l, cmTarget const* r) const ::operator()(cmTarget const* l, cmTarget const* r) const
{ {
// Make sure ALL_BUILD is first so it is the default active project. // Make sure ALL_BUILD is first so it is the default active project.
if(strcmp(r->GetName(), "ALL_BUILD") == 0) if(r->GetName() == "ALL_BUILD")
{ {
return false; return false;
} }
if(strcmp(l->GetName(), "ALL_BUILD") == 0) if(l->GetName() == "ALL_BUILD")
{ {
return true; return true;
} }
return strcmp(l->GetName(), r->GetName()) < 0; return strcmp(l->GetName().c_str(), r->GetName().c_str()) < 0;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -104,8 +104,8 @@ protected:
VSDependMap VSTargetDepends; VSDependMap VSTargetDepends;
void ComputeVSTargetDepends(cmTarget&); void ComputeVSTargetDepends(cmTarget&);
bool CheckTargetLinks(cmTarget& target, const char* name); bool CheckTargetLinks(cmTarget& target, const std::string& name);
std::string GetUtilityForTarget(cmTarget& target, const char*); std::string GetUtilityForTarget(cmTarget& target, const std::string&);
virtual std::string WriteUtilityDepend(cmTarget const*) = 0; virtual std::string WriteUtilityDepend(cmTarget const*) = 0;
std::string GetUtilityDepend(cmTarget const* target); std::string GetUtilityDepend(cmTarget const* target);
typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap; typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap;

View File

@ -263,7 +263,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
const char* makeProgram, const char* makeProgram,
const char* projectName, const char* projectName,
const char* /*projectDir*/, const char* /*projectDir*/,
const char* targetName, const std::string& targetName,
const char* config, const char* config,
bool /*fast*/, bool /*fast*/,
std::vector<std::string> const& makeOptions) std::vector<std::string> const& makeOptions)
@ -283,10 +283,11 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
makeCommand.push_back(projectArg); makeCommand.push_back(projectArg);
bool clean = false; bool clean = false;
if ( targetName && strcmp(targetName, "clean") == 0 ) std::string realTarget = targetName;
if ( realTarget == "clean" )
{ {
clean = true; clean = true;
targetName = "ALL_BUILD"; realTarget = "ALL_BUILD";
} }
if(clean) if(clean)
{ {
@ -302,9 +303,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
{ {
config = 0; config = 0;
} }
if (targetName && strlen(targetName)) if (!realTarget.empty())
{ {
makeCommand.push_back(targetName); makeCommand.push_back(realTarget);
} }
else else
{ {
@ -1737,7 +1738,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{ {
cmSystemTools::Error cmSystemTools::Error
("CMake can not determine linker language for target: ", ("CMake can not determine linker language for target: ",
target.GetName()); target.GetName().c_str());
return; return;
} }
@ -2420,7 +2421,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
cmXCodeObject* target = cmXCodeObject* target =
this->CreateObject(cmXCodeObject::PBXAggregateTarget); this->CreateObject(cmXCodeObject::PBXAggregateTarget);
target->SetComment(cmtarget.GetName()); target->SetComment(cmtarget.GetName().c_str());
cmXCodeObject* buildPhases = cmXCodeObject* buildPhases =
this->CreateObject(cmXCodeObject::OBJECT_LIST); this->CreateObject(cmXCodeObject::OBJECT_LIST);
std::vector<cmXCodeObject*> emptyContentVector; std::vector<cmXCodeObject*> emptyContentVector;
@ -2621,7 +2622,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
fileRef->AddAttribute("refType", this->CreateString("0")); fileRef->AddAttribute("refType", this->CreateString("0"));
fileRef->AddAttribute("sourceTree", fileRef->AddAttribute("sourceTree",
this->CreateString("BUILT_PRODUCTS_DIR")); this->CreateString("BUILT_PRODUCTS_DIR"));
fileRef->SetComment(cmtarget.GetName()); fileRef->SetComment(cmtarget.GetName().c_str());
target->AddAttribute("productReference", target->AddAttribute("productReference",
this->CreateObjectReference(fileRef)); this->CreateObjectReference(fileRef));
if(const char* productType = this->GetTargetProductType(cmtarget)) if(const char* productType = this->GetTargetProductType(cmtarget))
@ -2654,8 +2655,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name, std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
const char* id) const std::string& id)
{ {
std::string guidStoreName = name; std::string guidStoreName = name;
guidStoreName += "_GUID_CMAKE"; guidStoreName += "_GUID_CMAKE";
@ -2668,7 +2669,7 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name,
} }
this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(),
id, "Stored Xcode object GUID", cmCacheManager::INTERNAL); id.c_str(), "Stored Xcode object GUID", cmCacheManager::INTERNAL);
return id; return id;
} }

View File

@ -58,7 +58,7 @@ public:
const char* makeProgram, const char* makeProgram,
const char* projectName, const char* projectName,
const char* projectDir, const char* projectDir,
const char* targetName, const std::string& targetName,
const char* config, const char* config,
bool fast, bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>() std::vector<std::string> const& makeOptions = std::vector<std::string>()
@ -129,7 +129,7 @@ private:
); );
cmXCodeObject* FindXCodeTarget(cmTarget const*); cmXCodeObject* FindXCodeTarget(cmTarget const*);
std::string GetOrCreateId(const char* name, const char* id); std::string GetOrCreateId(const std::string& name, const std::string& id);
// create cmXCodeObject from these functions so that memory can be managed // create cmXCodeObject from these functions so that memory can be managed
// correctly. All objects created are stored in this->XCodeObjects. // correctly. All objects created are stored in this->XCodeObjects.

View File

@ -300,7 +300,7 @@ void cmGraphVizWriter::WriteFooter(cmGeneratedFileStream& str) const
} }
void cmGraphVizWriter::WriteConnections(const char* targetName, void cmGraphVizWriter::WriteConnections(const std::string& targetName,
std::set<std::string>& insertedNodes, std::set<std::string>& insertedNodes,
std::set<std::string>& insertedConnections, std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const cmGeneratedFileStream& str) const
@ -359,7 +359,7 @@ void cmGraphVizWriter::WriteConnections(const char* targetName,
} }
void cmGraphVizWriter::WriteDependerConnections(const char* targetName, void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName,
std::set<std::string>& insertedNodes, std::set<std::string>& insertedNodes,
std::set<std::string>& insertedConnections, std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const cmGeneratedFileStream& str) const
@ -444,7 +444,7 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName,
} }
void cmGraphVizWriter::WriteNode(const char* targetName, void cmGraphVizWriter::WriteNode(const std::string& targetName,
const cmTarget* target, const cmTarget* target,
std::set<std::string>& insertedNodes, std::set<std::string>& insertedNodes,
cmGeneratedFileStream& str) const cmGeneratedFileStream& str) const
@ -558,7 +558,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
} }
bool cmGraphVizWriter::IgnoreThisTarget(const char* name) bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name)
{ {
for(std::vector<cmsys::RegularExpression>::iterator itvIt for(std::vector<cmsys::RegularExpression>::iterator itvIt
= this->TargetsToIgnoreRegex.begin(); = this->TargetsToIgnoreRegex.begin();

View File

@ -44,23 +44,23 @@ protected:
void WriteHeader(cmGeneratedFileStream& str) const; void WriteHeader(cmGeneratedFileStream& str) const;
void WriteConnections(const char* targetName, void WriteConnections(const std::string& targetName,
std::set<std::string>& insertedNodes, std::set<std::string>& insertedNodes,
std::set<std::string>& insertedConnections, std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const; cmGeneratedFileStream& str) const;
void WriteDependerConnections(const char* targetName, void WriteDependerConnections(const std::string& targetName,
std::set<std::string>& insertedNodes, std::set<std::string>& insertedNodes,
std::set<std::string>& insertedConnections, std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const; cmGeneratedFileStream& str) const;
void WriteNode(const char* targetName, const cmTarget* target, void WriteNode(const std::string& targetName, const cmTarget* target,
std::set<std::string>& insertedNodes, std::set<std::string>& insertedNodes,
cmGeneratedFileStream& str) const; cmGeneratedFileStream& str) const;
void WriteFooter(cmGeneratedFileStream& str) const; void WriteFooter(cmGeneratedFileStream& str) const;
bool IgnoreThisTarget(const char* name); bool IgnoreThisTarget(const std::string& name);
bool GenerateForTargetType(cmTarget::TargetType targetType) const; bool GenerateForTargetType(cmTarget::TargetType targetType) const;

View File

@ -781,7 +781,7 @@ void cmLocalGenerator
{ {
cmSystemTools::Error cmSystemTools::Error
("CMake can not determine linker language for target: ", ("CMake can not determine linker language for target: ",
target.Target->GetName()); target.Target->GetName().c_str());
return; return;
} }
// if the language is not in the set lang then create custom // if the language is not in the set lang then create custom
@ -1695,7 +1695,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
{ {
cmSystemTools::Error cmSystemTools::Error
("CMake can not determine linker language for target: ", ("CMake can not determine linker language for target: ",
target->Target->GetName()); target->Target->GetName().c_str());
return; return;
} }
this->AddLanguageFlags(flags, linkLanguage, buildType.c_str()); this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
@ -2012,7 +2012,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmLocalGenerator::GetRealDependency(const char* inName, bool cmLocalGenerator::GetRealDependency(const std::string& inName,
const char* config, const char* config,
std::string& dep) std::string& dep)
{ {
@ -2040,7 +2040,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
{ {
// make sure it is not just a coincidence that the target name // make sure it is not just a coincidence that the target name
// found is part of the inName // found is part of the inName
if(cmSystemTools::FileIsFullPath(inName)) if(cmSystemTools::FileIsFullPath(inName.c_str()))
{ {
std::string tLocation; std::string tLocation;
if(target->GetType() >= cmTarget::EXECUTABLE && if(target->GetType() >= cmTarget::EXECUTABLE &&
@ -2088,7 +2088,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
} }
// The name was not that of a CMake target. It must name a file. // The name was not that of a CMake target. It must name a file.
if(cmSystemTools::FileIsFullPath(inName)) if(cmSystemTools::FileIsFullPath(inName.c_str()))
{ {
// This is a full path. Return it as given. // This is a full path. Return it as given.
dep = inName; dep = inName;
@ -3474,7 +3474,7 @@ static void cmLGInfoProp(cmMakefile* mf, cmTarget* target,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
const char* targetName, const std::string& targetName,
const char* fname) const char* fname)
{ {
// Find the Info.plist template. // Find the Info.plist template.
@ -3503,7 +3503,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
// back to the directory-level values set by the user. // back to the directory-level values set by the user.
cmMakefile* mf = this->Makefile; cmMakefile* mf = this->Makefile;
mf->PushScope(); mf->PushScope();
mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName); mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName.c_str());
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING");
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE");
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER");
@ -3518,8 +3518,8 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target,
const char* targetName, const std::string& targetName,
const char* fname) const char* fname)
{ {
// Find the Info.plist template. // Find the Info.plist template.
const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST"); const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
@ -3547,7 +3547,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target,
// back to the directory-level values set by the user. // back to the directory-level values set by the user.
cmMakefile* mf = this->Makefile; cmMakefile* mf = this->Makefile;
mf->PushScope(); mf->PushScope();
mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName); mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName.c_str());
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING");

View File

@ -195,7 +195,7 @@ public:
* the source directory of this generator. This should only be * the source directory of this generator. This should only be
* used for dependencies of custom commands. * used for dependencies of custom commands.
*/ */
bool GetRealDependency(const char* name, const char* config, bool GetRealDependency(const std::string& name, const char* config,
std::string& dep); std::string& dep);
///! for existing files convert to output path and short path if spaces ///! for existing files convert to output path and short path if spaces
@ -339,14 +339,14 @@ public:
/** /**
* Generate a Mac OS X application bundle Info.plist file. * Generate a Mac OS X application bundle Info.plist file.
*/ */
void GenerateAppleInfoPList(cmTarget* target, const char* targetName, void GenerateAppleInfoPList(cmTarget* target, const std::string& targetName,
const char* fname); const char* fname);
/** /**
* Generate a Mac OS X framework Info.plist file. * Generate a Mac OS X framework Info.plist file.
*/ */
void GenerateFrameworkInfoPList(cmTarget* target, void GenerateFrameworkInfoPList(cmTarget* target,
const char* targetName, const std::string& targetName,
const char* fname); const char* fname);
/** Construct a comment for a custom command. */ /** Construct a comment for a custom command. */
std::string ConstructComment(const cmCustomCommand& cc, std::string ConstructComment(const cmCustomCommand& cc,

View File

@ -550,14 +550,14 @@ void
cmLocalUnixMakefileGenerator3 cmLocalUnixMakefileGenerator3
::WriteMakeRule(std::ostream& os, ::WriteMakeRule(std::ostream& os,
const char* comment, const char* comment,
const char* target, const std::string& target,
const std::vector<std::string>& depends, const std::vector<std::string>& depends,
const std::vector<std::string>& commands, const std::vector<std::string>& commands,
bool symbolic, bool symbolic,
bool in_help) bool in_help)
{ {
// Make sure there is a target. // Make sure there is a target.
if(!target || !*target) if(target.empty())
{ {
cmSystemTools::Error("No target for WriteMakeRule! called with comment: ", cmSystemTools::Error("No target for WriteMakeRule! called with comment: ",
comment); comment);
@ -859,11 +859,11 @@ void cmLocalUnixMakefileGenerator3
void void
cmLocalUnixMakefileGenerator3 cmLocalUnixMakefileGenerator3
::WriteConvenienceRule(std::ostream& ruleFileStream, ::WriteConvenienceRule(std::ostream& ruleFileStream,
const char* realTarget, const std::string& realTarget,
const char* helpTarget) const std::string& helpTarget)
{ {
// A rule is only needed if the names are different. // A rule is only needed if the names are different.
if(strcmp(realTarget, helpTarget) != 0) if(realTarget != helpTarget)
{ {
// The helper target depends on the real target. // The helper target depends on the real target.
std::vector<std::string> depends; std::vector<std::string> depends;
@ -2034,7 +2034,7 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmLocalUnixMakefileGenerator3 cmLocalUnixMakefileGenerator3
::GetRecursiveMakeCall(const char *makefile, const char* tgt) ::GetRecursiveMakeCall(const char *makefile, const std::string& tgt)
{ {
// Call make on the given file. // Call make on the given file.
std::string cmd; std::string cmd;
@ -2059,7 +2059,7 @@ cmLocalUnixMakefileGenerator3
} }
// Add the target. // Add the target.
if (tgt && tgt[0] != '\0') if (!tgt.empty())
{ {
// The make target is always relative to the top of the build tree. // The make target is always relative to the top of the build tree.
std::string tgt2 = this->Convert(tgt, HOME_OUTPUT); std::string tgt2 = this->Convert(tgt, HOME_OUTPUT);

View File

@ -55,7 +55,7 @@ public:
// Write out a make rule // Write out a make rule
void WriteMakeRule(std::ostream& os, void WriteMakeRule(std::ostream& os,
const char* comment, const char* comment,
const char* target, const std::string& target,
const std::vector<std::string>& depends, const std::vector<std::string>& depends,
const std::vector<std::string>& commands, const std::vector<std::string>& commands,
bool symbolic, bool symbolic,
@ -168,7 +168,8 @@ public:
void WriteDivider(std::ostream& os); void WriteDivider(std::ostream& os);
/** used to create a recursive make call */ /** used to create a recursive make call */
std::string GetRecursiveMakeCall(const char *makefile, const char* tgt); std::string GetRecursiveMakeCall(const char *makefile,
const std::string& tgt);
// append flags to a string // append flags to a string
virtual void AppendFlags(std::string& flags, const char* newFlags); virtual void AppendFlags(std::string& flags, const char* newFlags);
@ -273,8 +274,8 @@ protected:
void WriteConvenienceRule(std::ostream& ruleFileStream, void WriteConvenienceRule(std::ostream& ruleFileStream,
const char* realTarget, const std::string& realTarget,
const char* helpTarget); const std::string& helpTarget);
void WriteTargetDependRule(std::ostream& ruleFileStream, void WriteTargetDependRule(std::ostream& ruleFileStream,
cmTarget& target); cmTarget& target);

View File

@ -186,7 +186,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
// //
extern std::string GetVS6TargetName(const std::string& targetName); extern std::string GetVS6TargetName(const std::string& targetName);
void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname, void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname,
cmTarget &target) cmTarget &target)
{ {
// add to the list of projects // add to the list of projects
@ -263,7 +263,7 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
const char *libName, const std::string& libName,
cmTarget &target) cmTarget &target)
{ {
// For utility targets need custom command since pre- and post- // For utility targets need custom command since pre- and post-
@ -372,7 +372,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
void cmLocalVisualStudio6Generator void cmLocalVisualStudio6Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget& target, ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
std::ostream &fout, const char *libName) std::ostream &fout, const std::string& libName)
{ {
cmGeneratorTarget* gt = cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target); this->GlobalGenerator->GetGeneratorTarget(&target);
@ -572,9 +572,9 @@ cmLocalVisualStudio6Generator
{ {
// Create a fake output that forces the rule to run. // Create a fake output that forces the rule to run.
char* output = new char[(strlen(this->Makefile->GetStartOutputDirectory()) + char* output = new char[(strlen(this->Makefile->GetStartOutputDirectory()) +
strlen(target.GetName()) + 30)]; target.GetName().size() + 30)];
sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(), sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(),
target.GetName(), count); target.GetName().c_str(), count);
std::string comment = this->ConstructComment(origCommand, "<hack>"); std::string comment = this->ConstructComment(origCommand, "<hack>");
// Add the rule with the given dependencies and commands. // Add the rule with the given dependencies and commands.
@ -699,7 +699,7 @@ void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout)
void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
const char* libName, const std::string& libName,
cmTarget& target) cmTarget& target)
{ {
std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
@ -813,8 +813,8 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target,
// look for custom rules on a target and collect them together // look for custom rules on a target and collect them together
std::string std::string
cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target,
const char* configName, const char* configName,
const char * /* libName */) const std::string& /* libName */)
{ {
if (target.GetType() >= cmTarget::UTILITY ) if (target.GetType() >= cmTarget::UTILITY )
{ {
@ -926,7 +926,7 @@ cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target,
void cmLocalVisualStudio6Generator void cmLocalVisualStudio6Generator
::WriteDSPHeader(std::ostream& fout, ::WriteDSPHeader(std::ostream& fout,
const char *libName, cmTarget &target, const std::string& libName, cmTarget &target,
std::vector<cmSourceGroup> &) std::vector<cmSourceGroup> &)
{ {
bool targetBuilds = (target.GetType() >= cmTarget::EXECUTABLE && bool targetBuilds = (target.GetType() >= cmTarget::EXECUTABLE &&
@ -1257,7 +1257,7 @@ void cmLocalVisualStudio6Generator
{ {
cmSystemTools::Error cmSystemTools::Error
("CMake can not determine linker language for target: ", ("CMake can not determine linker language for target: ",
target.GetName()); target.GetName().c_str());
return; return;
} }
@ -1679,7 +1679,7 @@ void cmLocalVisualStudio6Generator
{ {
cmSystemTools::Error cmSystemTools::Error
("CMake can not determine linker language for target: ", ("CMake can not determine linker language for target: ",
target.GetName()); target.GetName().c_str());
return; return;
} }
// if CXX is on and the target contains cxx code then add the cxx flags // if CXX is on and the target contains cxx code then add the cxx flags

View File

@ -48,7 +48,7 @@ public:
/** /**
* Specify the type of the build: static, dll, or executable. * Specify the type of the build: static, dll, or executable.
*/ */
void SetBuildType(BuildType, const char* libName, cmTarget&); void SetBuildType(BuildType, const std::string& libName, cmTarget&);
virtual std::string GetTargetDirectory(cmTarget const& target) const; virtual std::string GetTargetDirectory(cmTarget const& target) const;
virtual std::string ComputeLongestObjectDirectory(cmTarget&) const; virtual std::string ComputeLongestObjectDirectory(cmTarget&) const;
@ -56,15 +56,15 @@ private:
std::string DSPHeaderTemplate; std::string DSPHeaderTemplate;
std::string DSPFooterTemplate; std::string DSPFooterTemplate;
void CreateSingleDSP(const char *lname, cmTarget &tgt); void CreateSingleDSP(const std::string& lname, cmTarget &tgt);
void WriteDSPFile(std::ostream& fout, const char *libName, void WriteDSPFile(std::ostream& fout, const std::string& libName,
cmTarget &tgt); cmTarget &tgt);
void WriteDSPBeginGroup(std::ostream& fout, void WriteDSPBeginGroup(std::ostream& fout,
const char* group, const char* group,
const char* filter); const char* filter);
void WriteDSPEndGroup(std::ostream& fout); void WriteDSPEndGroup(std::ostream& fout);
void WriteDSPHeader(std::ostream& fout, const char *libName, void WriteDSPHeader(std::ostream& fout, const std::string& libName,
cmTarget &tgt, std::vector<cmSourceGroup> &sgs); cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
void WriteDSPFooter(std::ostream& fout); void WriteDSPFooter(std::ostream& fout);
@ -77,14 +77,14 @@ private:
std::vector<std::string>& depends, std::vector<std::string>& depends,
const cmCustomCommand& origCommand); const cmCustomCommand& origCommand);
void WriteGroup(const cmSourceGroup *sg, cmTarget& target, void WriteGroup(const cmSourceGroup *sg, cmTarget& target,
std::ostream &fout, const char *libName); std::ostream &fout, const std::string& libName);
class EventWriter; class EventWriter;
friend class EventWriter; friend class EventWriter;
cmsys::auto_ptr<cmCustomCommand> cmsys::auto_ptr<cmCustomCommand>
MaybeCreateOutputDir(cmTarget& target, const char* config); MaybeCreateOutputDir(cmTarget& target, const char* config);
std::string CreateTargetRules(cmTarget &target, std::string CreateTargetRules(cmTarget &target,
const char* configName, const char* configName,
const char *libName); const std::string& libName);
void ComputeLinkOptions(cmTarget& target, const char* configName, void ComputeLinkOptions(cmTarget& target, const char* configName,
const std::string extraOptions, const std::string extraOptions,
std::string& options); std::string& options);

View File

@ -83,7 +83,7 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
if(path) if(path)
{ {
this->ReadAndStoreExternalGUID( this->ReadAndStoreExternalGUID(
l->second.GetName(), path); l->second.GetName().c_str(), path);
} }
else else
{ {
@ -334,8 +334,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
} }
void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout, void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout,
const char *libName, const std::string& libName,
cmTarget &target) cmTarget &target)
{ {
std::vector<std::string> *configs = std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *> static_cast<cmGlobalVisualStudio7Generator *>
@ -637,9 +637,9 @@ private:
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
const char* configName, const char* configName,
const char *libName, const std::string& libName,
cmTarget &target) cmTarget &target)
{ {
const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
if(!mfcFlag) if(!mfcFlag)
@ -694,7 +694,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
{ {
cmSystemTools::Error cmSystemTools::Error
("CMake can not determine linker language for target: ", ("CMake can not determine linker language for target: ",
target.GetName()); target.GetName().c_str());
return; return;
} }
if(linkLanguage == "C" || linkLanguage == "CXX" if(linkLanguage == "C" || linkLanguage == "CXX"
@ -1380,7 +1380,7 @@ cmLocalVisualStudio7Generator
} }
void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
const char *libName, const std::string& libName,
cmTarget &target) cmTarget &target)
{ {
// get the configurations // get the configurations
@ -1627,7 +1627,7 @@ cmLocalVisualStudio7Generator
bool cmLocalVisualStudio7Generator bool cmLocalVisualStudio7Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget& target, ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
std::ostream &fout, const char *libName, std::ostream &fout, const std::string& libName,
std::vector<std::string> *configs) std::vector<std::string> *configs)
{ {
const std::vector<const cmSourceFile *> &sourceFiles = const std::vector<const cmSourceFile *> &sourceFiles =
@ -1906,7 +1906,7 @@ void cmLocalVisualStudio7Generator
::OutputTargetRules(std::ostream& fout, ::OutputTargetRules(std::ostream& fout,
const char* configName, const char* configName,
cmTarget &target, cmTarget &target,
const char * /*libName*/) const std::string& /*libName*/)
{ {
if (target.GetType() > cmTarget::GLOBAL_TARGET) if (target.GetType() > cmTarget::GLOBAL_TARGET)
{ {
@ -1966,7 +1966,7 @@ void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout,
void void
cmLocalVisualStudio7Generator cmLocalVisualStudio7Generator
::WriteProjectStartFortran(std::ostream& fout, ::WriteProjectStartFortran(std::ostream& fout,
const char *libName, const std::string& libName,
cmTarget & target) cmTarget & target)
{ {
@ -2017,7 +2017,7 @@ cmLocalVisualStudio7Generator
} }
this->WriteProjectSCC(fout, target); this->WriteProjectSCC(fout, target);
fout<< "\tKeyword=\"" << keyword << "\">\n" fout<< "\tKeyword=\"" << keyword << "\">\n"
<< "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n" << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\">\n"
<< "\t<Platforms>\n" << "\t<Platforms>\n"
<< "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n" << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n"
<< "\t</Platforms>\n"; << "\t</Platforms>\n";
@ -2026,7 +2026,7 @@ cmLocalVisualStudio7Generator
void void
cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
const char *libName, const std::string& libName,
cmTarget & target, cmTarget & target,
std::vector<cmSourceGroup> &) std::vector<cmSourceGroup> &)
{ {
@ -2049,7 +2049,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
const char* projLabel = target.GetProperty("PROJECT_LABEL"); const char* projLabel = target.GetProperty("PROJECT_LABEL");
if(!projLabel) if(!projLabel)
{ {
projLabel = libName; projLabel = libName.c_str();
} }
const char* keyword = target.GetProperty("VS_KEYWORD"); const char* keyword = target.GetProperty("VS_KEYWORD");
if(!keyword) if(!keyword)
@ -2061,7 +2061,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
fout << "\tName=\"" << projLabel << "\"\n"; fout << "\tName=\"" << projLabel << "\"\n";
if(this->Version >= VS8) if(this->Version >= VS8)
{ {
fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n"; fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n";
} }
this->WriteProjectSCC(fout, target); this->WriteProjectSCC(fout, target);
if(const char* targetFrameworkVersion = if(const char* targetFrameworkVersion =

View File

@ -74,29 +74,29 @@ private:
const char* configName); const char* configName);
void FixGlobalTargets(); void FixGlobalTargets();
void WriteProjectFiles(); void WriteProjectFiles();
void WriteVCProjHeader(std::ostream& fout, const char *libName, void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
cmTarget &tgt, std::vector<cmSourceGroup> &sgs); cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
void WriteVCProjFooter(std::ostream& fout, cmTarget &target); void WriteVCProjFooter(std::ostream& fout, cmTarget &target);
void WriteVCProjFile(std::ostream& fout, const char *libName, void WriteVCProjFile(std::ostream& fout, const std::string& libName,
cmTarget &tgt); cmTarget &tgt);
void WriteConfigurations(std::ostream& fout, void WriteConfigurations(std::ostream& fout,
const char *libName, cmTarget &tgt); const std::string& libName, cmTarget &tgt);
void WriteConfiguration(std::ostream& fout, void WriteConfiguration(std::ostream& fout,
const char* configName, const char* configName,
const char* libName, cmTarget &tgt); const std::string& libName, cmTarget &tgt);
std::string EscapeForXML(const char* s); std::string EscapeForXML(const char* s);
std::string ConvertToXMLOutputPath(const char* path); std::string ConvertToXMLOutputPath(const char* path);
std::string ConvertToXMLOutputPathSingle(const char* path); std::string ConvertToXMLOutputPathSingle(const char* path);
void OutputTargetRules(std::ostream& fout, const char* configName, void OutputTargetRules(std::ostream& fout, const char* configName,
cmTarget &target, const char *libName); cmTarget &target, const std::string& libName);
void OutputBuildTool(std::ostream& fout, const char* configName, void OutputBuildTool(std::ostream& fout, const char* configName,
cmTarget& t, const Options& targetOptions); cmTarget& t, const Options& targetOptions);
void OutputLibraryDirectories(std::ostream& fout, void OutputLibraryDirectories(std::ostream& fout,
std::vector<std::string> const& dirs); std::vector<std::string> const& dirs);
void WriteProjectSCC(std::ostream& fout, cmTarget& target); void WriteProjectSCC(std::ostream& fout, cmTarget& target);
void WriteProjectStart(std::ostream& fout, const char *libName, void WriteProjectStart(std::ostream& fout, const std::string& libName,
cmTarget &tgt, std::vector<cmSourceGroup> &sgs); cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
void WriteProjectStartFortran(std::ostream& fout, const char *libName, void WriteProjectStartFortran(std::ostream& fout, const std::string& libName,
cmTarget &tgt); cmTarget &tgt);
void WriteVCProjBeginGroup(std::ostream& fout, void WriteVCProjBeginGroup(std::ostream& fout,
const char* group, const char* group,
@ -111,7 +111,8 @@ private:
bool WriteGroup(const cmSourceGroup *sg, bool WriteGroup(const cmSourceGroup *sg,
cmTarget& target, std::ostream &fout, cmTarget& target, std::ostream &fout,
const char *libName, std::vector<std::string> *configs); const std::string& libName,
std::vector<std::string> *configs);
friend class cmLocalVisualStudio7GeneratorFCInfo; friend class cmLocalVisualStudio7GeneratorFCInfo;
friend class cmLocalVisualStudio7GeneratorInternals; friend class cmLocalVisualStudio7GeneratorInternals;

View File

@ -878,7 +878,7 @@ void cmMakefile::ConfigureFinalPass()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmMakefile::AddCustomCommandToTarget(const char* target, cmMakefile::AddCustomCommandToTarget(const std::string& target,
const std::vector<std::string>& depends, const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, const cmCustomCommandLines& commandLines,
cmTarget::CustomCommandType type, cmTarget::CustomCommandType type,
@ -1120,7 +1120,7 @@ cmMakefile::AddCustomCommandToOutput(const char* output,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmMakefile::AddCustomCommandOldStyle(const char* target, cmMakefile::AddCustomCommandOldStyle(const std::string& target,
const std::vector<std::string>& outputs, const std::vector<std::string>& outputs,
const std::vector<std::string>& depends, const std::vector<std::string>& depends,
const char* source, const char* source,
@ -1129,7 +1129,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
{ {
// Translate the old-style signature to one of the new-style // Translate the old-style signature to one of the new-style
// signatures. // signatures.
if(strcmp(source, target) == 0) if(source == target)
{ {
// In the old-style signature if the source and target were the // In the old-style signature if the source and target were the
// same then it added a post-build rule to the target. Preserve // same then it added a post-build rule to the target. Preserve
@ -1179,7 +1179,8 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
else else
{ {
cmSystemTools::Error("Attempt to add a custom rule to a target " cmSystemTools::Error("Attempt to add a custom rule to a target "
"that does not exist yet for target ", target); "that does not exist yet for target ",
target.c_str());
return; return;
} }
} }
@ -1453,7 +1454,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
return true; return true;
} }
void cmMakefile::AddLinkLibrary(const char* lib, void cmMakefile::AddLinkLibrary(const std::string& lib,
cmTarget::LinkLibraryType llt) cmTarget::LinkLibraryType llt)
{ {
cmTarget::LibraryID tmp; cmTarget::LibraryID tmp;
@ -1462,8 +1463,8 @@ void cmMakefile::AddLinkLibrary(const char* lib,
this->LinkLibraries.push_back(tmp); this->LinkLibraries.push_back(tmp);
} }
void cmMakefile::AddLinkLibraryForTarget(const char *target, void cmMakefile::AddLinkLibraryForTarget(const std::string& target,
const char* lib, const std::string& lib,
cmTarget::LinkLibraryType llt) cmTarget::LinkLibraryType llt)
{ {
cmTargets::iterator i = this->Targets.find(target); cmTargets::iterator i = this->Targets.find(target);
@ -1500,8 +1501,8 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target,
} }
} }
void cmMakefile::AddLinkDirectoryForTarget(const char *target, void cmMakefile::AddLinkDirectoryForTarget(const std::string& target,
const char* d) const std::string& d)
{ {
cmTargets::iterator i = this->Targets.find(target); cmTargets::iterator i = this->Targets.find(target);
if ( i != this->Targets.end()) if ( i != this->Targets.end())
@ -1520,46 +1521,37 @@ void cmMakefile::AddLinkDirectoryForTarget(const char *target,
{ {
cmSystemTools::Error cmSystemTools::Error
("Attempt to add link directories to non-existent target: ", ("Attempt to add link directories to non-existent target: ",
target, " for directory ", d); target.c_str(), " for directory ", d.c_str());
} }
} }
void cmMakefile::AddLinkLibrary(const char* lib) void cmMakefile::AddLinkLibrary(const std::string& lib)
{ {
this->AddLinkLibrary(lib,cmTarget::GENERAL); this->AddLinkLibrary(lib,cmTarget::GENERAL);
} }
void cmMakefile::AddLinkDirectory(const char* dir) void cmMakefile::AddLinkDirectory(const std::string& dir)
{ {
// Don't add a link directory that is already present. Yes, this // Don't add a link directory that is already present. Yes, this
// linear search results in n^2 behavior, but n won't be getting // linear search results in n^2 behavior, but n won't be getting
// much bigger than 20. We cannot use a set because of order // much bigger than 20. We cannot use a set because of order
// dependency of the link search path. // dependency of the link search path.
if(!dir) if(dir.empty())
{ {
return; return;
} }
std::string newdir = dir;
// remove trailing slashes // remove trailing slashes
if(dir[strlen(dir)-1] == '/') if(*dir.rbegin() == '/')
{ {
std::string newdir = dir; newdir = dir.substr(0, dir.size()-1);
newdir = newdir.substr(0, newdir.size()-1);
if(std::find(this->LinkDirectories.begin(),
this->LinkDirectories.end(),
newdir.c_str()) == this->LinkDirectories.end())
{
this->LinkDirectories.push_back(newdir);
}
} }
else if(std::find(this->LinkDirectories.begin(),
this->LinkDirectories.end(), newdir)
== this->LinkDirectories.end())
{ {
if(std::find(this->LinkDirectories.begin(), this->LinkDirectories.push_back(dir);
this->LinkDirectories.end(), dir)
== this->LinkDirectories.end())
{
this->LinkDirectories.push_back(dir);
}
} }
} }
@ -1975,7 +1967,8 @@ void cmMakefile::SetProjectName(const char* p)
} }
void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) void cmMakefile::AddGlobalLinkInformation(const std::string& name,
cmTarget& target)
{ {
// for these targets do not add anything // for these targets do not add anything
switch(target.GetType()) switch(target.GetType())
@ -1996,13 +1989,14 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
} }
void cmMakefile::AddAlias(const char* lname, cmTarget *tgt) void cmMakefile::AddAlias(const std::string& lname, cmTarget *tgt)
{ {
this->AliasTargets[lname] = tgt; this->AliasTargets[lname] = tgt;
this->LocalGenerator->GetGlobalGenerator()->AddAlias(lname, tgt); this->LocalGenerator->GetGlobalGenerator()->AddAlias(lname, tgt);
} }
cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, cmTarget* cmMakefile::AddLibrary(const std::string& lname,
cmTarget::TargetType type,
const std::vector<std::string> &srcs, const std::vector<std::string> &srcs,
bool excludeFromAll) bool excludeFromAll)
{ {
@ -2048,7 +2042,7 @@ cmTarget* cmMakefile::AddExecutable(const char *exeName,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget* cmTarget*
cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name) cmMakefile::AddNewTarget(cmTarget::TargetType type, const std::string& name)
{ {
cmTargets::iterator it = cmTargets::iterator it =
this->Targets.insert(cmTargets::value_type(name, cmTarget())).first; this->Targets.insert(cmTargets::value_type(name, cmTarget())).first;
@ -3066,7 +3060,8 @@ void cmMakefile::ExpandSourceListArguments(
} }
int cmMakefile::TryCompile(const char *srcdir, const char *bindir, int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
const char *projectName, const char *targetName, const char *projectName,
const std::string& targetName,
bool fast, bool fast,
const std::vector<std::string> *cmakeArgs, const std::vector<std::string> *cmakeArgs,
std::string *output) std::string *output)
@ -4030,7 +4025,8 @@ void cmMakefile::DefineProperties(cmake *cm)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget* cmTarget*
cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type, cmMakefile::AddImportedTarget(const std::string& name,
cmTarget::TargetType type,
bool global) bool global)
{ {
// Create the target. // Create the target.
@ -4087,7 +4083,7 @@ bool cmMakefile::IsAlias(const std::string& name) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGeneratorTarget* cmGeneratorTarget*
cmMakefile::FindGeneratorTargetToUse(const char* name) const cmMakefile::FindGeneratorTargetToUse(const std::string& name) const
{ {
if (cmTarget *t = this->FindTargetToUse(name)) if (cmTarget *t = this->FindTargetToUse(name))
{ {

View File

@ -127,7 +127,7 @@ public:
* loaded commands, not as part of the usual build process. * loaded commands, not as part of the usual build process.
*/ */
int TryCompile(const char *srcdir, const char *bindir, int TryCompile(const char *srcdir, const char *bindir,
const char *projectName, const char *targetName, const char *projectName, const std::string& targetName,
bool fast, bool fast,
const std::vector<std::string> *cmakeArgs, const std::vector<std::string> *cmakeArgs,
std::string *output); std::string *output);
@ -168,7 +168,7 @@ public:
void Print() const; void Print() const;
/** Add a custom command to the build. */ /** Add a custom command to the build. */
void AddCustomCommandToTarget(const char* target, void AddCustomCommandToTarget(const std::string& target,
const std::vector<std::string>& depends, const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, const cmCustomCommandLines& commandLines,
cmTarget::CustomCommandType type, cmTarget::CustomCommandType type,
@ -190,7 +190,7 @@ public:
const char* comment, const char* workingDir, const char* comment, const char* workingDir,
bool replace = false, bool replace = false,
bool escapeOldStyle = true); bool escapeOldStyle = true);
void AddCustomCommandOldStyle(const char* target, void AddCustomCommandOldStyle(const std::string& target,
const std::vector<std::string>& outputs, const std::vector<std::string>& outputs,
const std::vector<std::string>& depends, const std::vector<std::string>& depends,
const char* source, const char* source,
@ -205,10 +205,11 @@ public:
void AddCompileOption(const char* option); void AddCompileOption(const char* option);
/** Create a new imported target with the name and type given. */ /** Create a new imported target with the name and type given. */
cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type, cmTarget* AddImportedTarget(const std::string& name,
cmTarget::TargetType type,
bool global); bool global);
cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name); cmTarget* AddNewTarget(cmTarget::TargetType type, const std::string& name);
/** /**
* Add an executable to the build. * Add an executable to the build.
@ -239,16 +240,16 @@ public:
/** /**
* Add a link library to the build. * Add a link library to the build.
*/ */
void AddLinkLibrary(const char*); void AddLinkLibrary(const std::string&);
void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type); void AddLinkLibrary(const std::string&, cmTarget::LinkLibraryType type);
void AddLinkLibraryForTarget(const char *tgt, const char*, void AddLinkLibraryForTarget(const std::string& tgt, const std::string&,
cmTarget::LinkLibraryType type); cmTarget::LinkLibraryType type);
void AddLinkDirectoryForTarget(const char *tgt, const char* d); void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d);
/** /**
* Add a link directory to the build. * Add a link directory to the build.
*/ */
void AddLinkDirectory(const char*); void AddLinkDirectory(const std::string&);
const std::vector<std::string>& GetLinkDirectories() const const std::vector<std::string>& GetLinkDirectories() const
{ {
@ -323,10 +324,10 @@ public:
/** /**
* Set the name of the library. * Set the name of the library.
*/ */
cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type, cmTarget* AddLibrary(const std::string& libname, cmTarget::TargetType type,
const std::vector<std::string> &srcs, const std::vector<std::string> &srcs,
bool excludeFromAll = false); bool excludeFromAll = false);
void AddAlias(const char *libname, cmTarget *tgt); void AddAlias(const std::string& libname, cmTarget *tgt);
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
/** /**
@ -534,7 +535,7 @@ public:
cmTarget* FindTargetToUse(const std::string& name, cmTarget* FindTargetToUse(const std::string& name,
bool excludeAliases = false) const; bool excludeAliases = false) const;
bool IsAlias(const std::string& name) const; bool IsAlias(const std::string& name) const;
cmGeneratorTarget* FindGeneratorTargetToUse(const char* name) const; cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
/** /**
* Mark include directories as system directories. * Mark include directories as system directories.
@ -878,7 +879,7 @@ public:
protected: protected:
// add link libraries and directories to the target // add link libraries and directories to the target
void AddGlobalLinkInformation(const char* name, cmTarget& target); void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
// Check for a an unused variable // Check for a an unused variable
void CheckForUnused(const char* reason, const std::string& name) const; void CheckForUnused(const char* reason, const std::string& name) const;

View File

@ -167,7 +167,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
if(linkLanguage.empty()) if(linkLanguage.empty())
{ {
cmSystemTools::Error("Cannot determine link language for target \"", cmSystemTools::Error("Cannot determine link language for target \"",
this->Target->GetName(), "\"."); this->Target->GetName().c_str(), "\".");
return; return;
} }

View File

@ -125,7 +125,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
depends, commands, true); depends, commands, true);
// Write the main driver rule to build everything in this target. // Write the main driver rule to build everything in this target.
this->WriteTargetDriverRule(this->Target->GetName(), false); this->WriteTargetDriverRule(this->Target->GetName().c_str(), false);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -243,7 +243,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
if(linkLanguage.empty()) if(linkLanguage.empty())
{ {
cmSystemTools::Error("Cannot determine link language for target \"", cmSystemTools::Error("Cannot determine link language for target \"",
this->Target->GetName(), "\"."); this->Target->GetName().c_str(), "\".");
return; return;
} }

View File

@ -1347,7 +1347,7 @@ cmMakefileTargetGenerator
// Write a make variable assignment that lists all objects for the // Write a make variable assignment that lists all objects for the
// target. // target.
variableName = variableName =
this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), this->LocalGenerator->CreateMakeVariable(this->Target->GetName().c_str(),
"_OBJECTS"); "_OBJECTS");
*this->BuildFileStream *this->BuildFileStream
<< "# Object files for target " << this->Target->GetName() << "\n" << "# Object files for target " << this->Target->GetName() << "\n"
@ -1382,7 +1382,7 @@ cmMakefileTargetGenerator
// Write a make variable assignment that lists all external objects // Write a make variable assignment that lists all external objects
// for the target. // for the target.
variableNameExternal = variableNameExternal =
this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), this->LocalGenerator->CreateMakeVariable(this->Target->GetName().c_str(),
"_EXTERNAL_OBJECTS"); "_EXTERNAL_OBJECTS");
*this->BuildFileStream *this->BuildFileStream
<< "\n" << "\n"
@ -1683,7 +1683,7 @@ void cmMakefileTargetGenerator
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmMakefileTargetGenerator::GetLinkRule( std::string cmMakefileTargetGenerator::GetLinkRule(
const cmStdString& linkRuleVar) const std::string& linkRuleVar)
{ {
std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
if(this->Target->HasImplibGNUtoMS()) if(this->Target->HasImplibGNUtoMS())

View File

@ -138,7 +138,7 @@ protected:
void AppendLinkDepends(std::vector<std::string>& depends); void AppendLinkDepends(std::vector<std::string>& depends);
// Lookup the link rule for this target. // Lookup the link rule for this target.
std::string GetLinkRule(const cmStdString& linkRuleVar); std::string GetLinkRule(const std::string& linkRuleVar);
/** In order to support parallel builds for custom commands with /** In order to support parallel builds for custom commands with
multiple outputs the outputs are given a serial order, and only multiple outputs the outputs are given a serial order, and only

View File

@ -105,7 +105,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
depends, commands, true); depends, commands, true);
// Write the main driver rule to build everything in this target. // Write the main driver rule to build everything in this target.
this->WriteTargetDriverRule(this->Target->GetName(), false); this->WriteTargetDriverRule(this->Target->GetName().c_str(), false);
// Write clean target // Write clean target
this->WriteTargetCleanRules(); this->WriteTargetCleanRules();

View File

@ -75,7 +75,7 @@ void cmNinjaNormalTargetGenerator::Generate()
if (this->TargetLinkLanguage.empty()) { if (this->TargetLinkLanguage.empty()) {
cmSystemTools::Error("CMake can not determine linker language for " cmSystemTools::Error("CMake can not determine linker language for "
"target: ", "target: ",
this->GetTarget()->GetName()); this->GetTarget()->GetName().c_str());
return; return;
} }

View File

@ -772,7 +772,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
makefile->AddDefinition("_qt_uic_options_options", makefile->AddDefinition("_qt_uic_options_options",
cmLocalGenerator::EscapeForCMake(uiFileOptions.c_str()).c_str()); cmLocalGenerator::EscapeForCMake(uiFileOptions.c_str()).c_str());
const char* targetName = target->GetName(); std::string targetName = target->GetName();
if (strcmp(qtVersion, "5") == 0) if (strcmp(qtVersion, "5") == 0)
{ {
cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic"); cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic");
@ -791,7 +791,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
if (!qt4Uic) if (!qt4Uic)
{ {
cmSystemTools::Error("Qt4::uic target not found ", cmSystemTools::Error("Qt4::uic target not found ",
targetName); targetName.c_str());
return; return;
} }
makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0)); makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0));
@ -799,7 +799,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
else else
{ {
cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and " cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and "
"Qt 5 ", targetName); "Qt 5 ", targetName.c_str());
} }
} }
@ -921,14 +921,14 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
makefile->AddDefinition("_qt_rcc_options_options", makefile->AddDefinition("_qt_rcc_options_options",
cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str()); cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str());
const char* targetName = target->GetName(); std::string targetName = target->GetName();
if (strcmp(qtVersion, "5") == 0) if (strcmp(qtVersion, "5") == 0)
{ {
cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc"); cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc");
if (!qt5Rcc) if (!qt5Rcc)
{ {
cmSystemTools::Error("Qt5::rcc target not found ", cmSystemTools::Error("Qt5::rcc target not found ",
targetName); targetName.c_str());
return; return;
} }
makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0)); makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0));
@ -939,7 +939,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
if (!qt4Rcc) if (!qt4Rcc)
{ {
cmSystemTools::Error("Qt4::rcc target not found ", cmSystemTools::Error("Qt4::rcc target not found ",
targetName); targetName.c_str());
return; return;
} }
makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0)); makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0));
@ -947,7 +947,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
else else
{ {
cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
"Qt 5 ", targetName); "Qt 5 ", targetName.c_str());
} }
} }

View File

@ -203,7 +203,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
// Lookup the generator. // Lookup the generator.
if(cmLocalGenerator* lg = if(cmLocalGenerator* lg =
(this->Makefile->GetLocalGenerator() (this->Makefile->GetLocalGenerator()
->GetGlobalGenerator()->FindLocalGenerator(dir.c_str()))) ->GetGlobalGenerator()->FindLocalGenerator(dir)))
{ {
// Use the makefile for the directory found. // Use the makefile for the directory found.
mf = lg->GetMakefile(); mf = lg->GetMakefile();

View File

@ -91,7 +91,7 @@ bool cmSetTargetPropertiesCommand
} }
bool cmSetTargetPropertiesCommand bool cmSetTargetPropertiesCommand
::SetOneTarget(const char *tname, ::SetOneTarget(const std::string& tname,
std::vector<std::string> &propertyPairs, std::vector<std::string> &propertyPairs,
cmMakefile *mf) cmMakefile *mf)
{ {

View File

@ -37,7 +37,7 @@ public:
/** /**
* Used by this command and cmSetPropertiesCommand * Used by this command and cmSetPropertiesCommand
*/ */
static bool SetOneTarget(const char *tname, static bool SetOneTarget(const std::string& tname,
std::vector<std::string> &propertyPairs, std::vector<std::string> &propertyPairs,
cmMakefile *mf); cmMakefile *mf);

View File

@ -234,7 +234,7 @@ void cmTarget::DefineProperties(cmake *cm)
"", "", true); "", "", true);
} }
void cmTarget::SetType(TargetType type, const char* name) void cmTarget::SetType(TargetType type, const std::string& name)
{ {
this->Name = name; this->Name = name;
// only add dependency information for library targets // only add dependency information for library targets
@ -415,7 +415,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::AddUtility(const char *u, cmMakefile *makefile) void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile)
{ {
this->Utilities.insert(u); this->Utilities.insert(u);
if(makefile) if(makefile)
@ -425,7 +425,8 @@ void cmTarget::AddUtility(const char *u, cmMakefile *makefile)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(const char *u) const cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
const std::string& u) const
{ {
std::map<cmStdString, cmListFileBacktrace>::const_iterator i = std::map<cmStdString, cmListFileBacktrace>::const_iterator i =
this->UtilityBacktraces.find(u); this->UtilityBacktraces.find(u);
@ -657,7 +658,7 @@ void cmTarget::ProcessSourceExpression(std::string const& expr)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::MergeLinkLibraries( cmMakefile& mf, void cmTarget::MergeLinkLibraries( cmMakefile& mf,
const char *selfname, const std::string& selfname,
const LinkLibraryVectorType& libs ) const LinkLibraryVectorType& libs )
{ {
// Only add on libraries we haven't added on before. // Only add on libraries we haven't added on before.
@ -675,7 +676,7 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::AddLinkDirectory(const char* d) void cmTarget::AddLinkDirectory(const std::string& d)
{ {
// Make sure we don't add unnecessary search directories. // Make sure we don't add unnecessary search directories.
if(this->LinkDirectoriesEmmitted.insert(d).second) if(this->LinkDirectoriesEmmitted.insert(d).second)
@ -720,7 +721,7 @@ cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::ClearDependencyInformation( cmMakefile& mf, void cmTarget::ClearDependencyInformation( cmMakefile& mf,
const char* target ) const std::string& target )
{ {
// Clear the dependencies. The cache variable must exist iff we are // Clear the dependencies. The cache variable must exist iff we are
// recording dependency information for this target. // recording dependency information for this target.
@ -844,9 +845,9 @@ std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static std::string targetNameGenex(const char *lib) static std::string targetNameGenex(const std::string& lib)
{ {
return std::string("$<TARGET_NAME:") + lib + ">"; return "$<TARGET_NAME:" + lib + ">";
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -908,7 +909,8 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::AddLinkLibrary(cmMakefile& mf, void cmTarget::AddLinkLibrary(cmMakefile& mf,
const char *target, const char* lib, const std::string& target,
const std::string& lib,
LinkLibraryType llt) LinkLibraryType llt)
{ {
cmTarget *tgt = this->Makefile->FindTargetToUse(lib); cmTarget *tgt = this->Makefile->FindTargetToUse(lib);
@ -917,7 +919,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
const std::string libName = (isNonImportedTarget && llt != GENERAL) const std::string libName = (isNonImportedTarget && llt != GENERAL)
? targetNameGenex(lib) ? targetNameGenex(lib)
: std::string(lib); : lib;
this->AppendProperty("LINK_LIBRARIES", this->AppendProperty("LINK_LIBRARIES",
this->GetDebugGeneratorExpressions(libName, this->GetDebugGeneratorExpressions(libName,
llt).c_str()); llt).c_str());
@ -925,7 +927,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
if (cmGeneratorExpression::Find(lib) != std::string::npos if (cmGeneratorExpression::Find(lib) != std::string::npos
|| (tgt && tgt->GetType() == INTERFACE_LIBRARY) || (tgt && tgt->GetType() == INTERFACE_LIBRARY)
|| (strcmp( target, lib ) == 0)) || (target == lib ))
{ {
return; return;
} }
@ -1469,7 +1471,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char* cmTarget::GetExportName() const std::string cmTarget::GetExportName() const
{ {
const char *exportName = this->GetProperty("EXPORT_NAME"); const char *exportName = this->GetProperty("EXPORT_NAME");
@ -2630,7 +2632,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
if (prop == "NAME") if (prop == "NAME")
{ {
return this->GetName(); return this->GetName().c_str();
} }
// Watch for special "computed" properties that are dependent on // Watch for special "computed" properties that are dependent on

View File

@ -93,13 +93,13 @@ public:
/** /**
* Set the target type * Set the target type
*/ */
void SetType(TargetType f, const char* name); void SetType(TargetType f, const std::string& name);
void MarkAsImported(); void MarkAsImported();
///! Set/Get the name of the target ///! Set/Get the name of the target
const char* GetName() const {return this->Name.c_str();} const std::string& GetName() const {return this->Name;}
const char* GetExportName() const; std::string GetExportName() const;
///! Set the cmMakefile that owns this target ///! Set the cmMakefile that owns this target
void SetMakefile(cmMakefile *mf); void SetMakefile(cmMakefile *mf);
@ -168,12 +168,12 @@ public:
/** /**
* Clear the dependency information recorded for this target, if any. * Clear the dependency information recorded for this target, if any.
*/ */
void ClearDependencyInformation(cmMakefile& mf, const char* target); void ClearDependencyInformation(cmMakefile& mf, const std::string& target);
// Check to see if a library is a framework and treat it different on Mac // Check to see if a library is a framework and treat it different on Mac
bool NameResolvesToFramework(const std::string& libname) const; bool NameResolvesToFramework(const std::string& libname) const;
void AddLinkLibrary(cmMakefile& mf, void AddLinkLibrary(cmMakefile& mf,
const char *target, const char* lib, const std::string& target, const std::string& lib,
LinkLibraryType llt); LinkLibraryType llt);
enum TLLSignature { enum TLLSignature {
KeywordTLLSignature, KeywordTLLSignature,
@ -182,12 +182,12 @@ public:
bool PushTLLCommandTrace(TLLSignature signature); bool PushTLLCommandTrace(TLLSignature signature);
void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const; void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const;
void MergeLinkLibraries( cmMakefile& mf, const char* selfname, void MergeLinkLibraries( cmMakefile& mf, const std::string& selfname,
const LinkLibraryVectorType& libs ); const LinkLibraryVectorType& libs );
const std::vector<std::string>& GetLinkDirectories() const; const std::vector<std::string>& GetLinkDirectories() const;
void AddLinkDirectory(const char* d); void AddLinkDirectory(const std::string& d);
/** /**
* Set the path where this target should be installed. This is relative to * Set the path where this target should be installed. This is relative to
@ -214,10 +214,10 @@ public:
* name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
* commands. It is not a full path nor does it have an extension. * commands. It is not a full path nor does it have an extension.
*/ */
void AddUtility(const char* u, cmMakefile *makefile = 0); void AddUtility(const std::string& u, cmMakefile *makefile = 0);
///! Get the utilities used by this target ///! Get the utilities used by this target
std::set<cmStdString>const& GetUtilities() const { return this->Utilities; } std::set<cmStdString>const& GetUtilities() const { return this->Utilities; }
cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const; cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
/** Finalize the target at the end of the Configure step. */ /** Finalize the target at the end of the Configure step. */
void FinishConfigure(); void FinishConfigure();

View File

@ -136,7 +136,7 @@ public:
return this->DependLibraries; return this->DependLibraries;
} }
void AddDependTarget(const char* configName, void AddDependTarget(const char* configName,
const char* tName) const std::string& tName)
{ {
if(!configName) if(!configName)
{ {