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

stringapi: Use strings for generator names

parent 24b5e93d
......@@ -101,8 +101,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
}
if ( this->GlobalGenerator )
{
if ( strcmp(this->GlobalGenerator->GetName(),
cmakeGeneratorName) != 0 )
if ( this->GlobalGenerator->GetName() != cmakeGeneratorName )
{
delete this->GlobalGenerator;
this->GlobalGenerator = 0;
......
......@@ -1127,9 +1127,10 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
// Full path libraries should specify a valid library file name.
// See documentation of CMP0008.
std::string generator = this->GlobalGenerator->GetName();
if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW &&
(strstr(this->GlobalGenerator->GetName(), "Visual Studio") ||
strstr(this->GlobalGenerator->GetName(), "Xcode")))
(generator.find("Visual Studio") != generator.npos ||
generator.find("Xcode") != generator.npos))
{
std::string file = cmSystemTools::GetFilenameName(item);
if(!this->ExtractAnyLibraryName.find(file.c_str()))
......
......@@ -20,13 +20,13 @@ void cmExternalMakefileProjectGenerator
}
std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
const char* globalGenerator,
const char* extraGenerator)
const std::string& globalGenerator,
const std::string& extraGenerator)
{
std::string fullName;
if (globalGenerator)
if (!globalGenerator.empty())
{
if (extraGenerator && *extraGenerator)
if (!extraGenerator.empty())
{
fullName = extraGenerator;
fullName += " - ";
......@@ -36,22 +36,22 @@ std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
return fullName;
}
const char* cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
const char* fullName)
std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
const std::string& fullName)
{
// at least one global generator must be supported
assert(!this->SupportedGlobalGenerators.empty());
if (fullName==0)
if (fullName.empty())
{
return 0;
return "";
}
std::string currentName = fullName;
// if we get only the short name, take the first global generator as default
if (currentName == this->GetName())
{
return this->SupportedGlobalGenerators[0].c_str();
return this->SupportedGlobalGenerators[0];
}
// otherwise search for the matching global generator
......@@ -63,8 +63,8 @@ const char* cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
if (this->CreateFullGeneratorName(it->c_str(), this->GetName())
== currentName)
{
return it->c_str();
return *it;
}
}
return 0;
return "";
}
......@@ -37,10 +37,10 @@ public:
virtual ~cmExternalMakefileProjectGenerator() {}
///! Get the name for this generator.
virtual const char* GetName() const = 0;
virtual std::string GetName() const = 0;
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
const char* fullName) const = 0;
const std::string& fullName) const = 0;
virtual void EnableLanguage(std::vector<std::string> const& languages,
cmMakefile *, bool optional);
......@@ -53,12 +53,13 @@ public:
{return this->SupportedGlobalGenerators;}
///! Get the name of the global generator for the given full name
const char* GetGlobalGeneratorName(const char* fullName);
std::string GetGlobalGeneratorName(const std::string& fullName);
/** Create a full name from the given global generator name and the
* extra generator name
*/
static std::string CreateFullGeneratorName(const char* globalGenerator,
const char* extraGenerator);
static std::string CreateFullGeneratorName(
const std::string& globalGenerator,
const std::string& extraGenerator);
///! Generate the project files, the Makefiles have already been generated
virtual void Generate() = 0;
......
......@@ -38,7 +38,7 @@ http://forums.codeblocks.org/index.php/topic,6789.0.html
//----------------------------------------------------------------------------
void cmExtraCodeBlocksGenerator
::GetDocumentation(cmDocumentationEntry& entry, const char*) const
::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates CodeBlocks project files.";
......@@ -761,7 +761,8 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
const std::string& target)
{
std::string command = make;
if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)
std::string generator = this->GlobalGenerator->GetName();
if (generator == "NMake Makefiles")
{
// For Windows ConvertToOutputPath already adds quotes when required.
// These need to be escaped, see
......@@ -772,7 +773,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
command += " VERBOSE=1 ";
command += target;
}
else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
else if (generator == "MinGW Makefiles")
{
// no escaping of spaces in this case, see
// http://public.kitware.com/Bug/view.php?id=10014
......@@ -783,7 +784,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
command += " VERBOSE=1 ";
command += target;
}
else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
else if (generator == "Ninja")
{
command += " -v ";
command += target;
......
......@@ -28,14 +28,14 @@ class cmExtraCodeBlocksGenerator : public cmExternalMakefileProjectGenerator
public:
cmExtraCodeBlocksGenerator();
virtual const char* GetName() const
virtual std::string GetName() const
{ return cmExtraCodeBlocksGenerator::GetActualName();}
static const char* GetActualName() { return "CodeBlocks";}
static std::string GetActualName() { return "CodeBlocks";}
static cmExternalMakefileProjectGenerator* New()
{ return new cmExtraCodeBlocksGenerator; }
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
const char* fullName) const;
const std::string& fullName) const;
virtual void Generate();
private:
......
......@@ -28,7 +28,7 @@
//----------------------------------------------------------------------------
void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry,
const char*) const
const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates CodeLite project files.";
......
......@@ -35,14 +35,14 @@ protected:
public:
cmExtraCodeLiteGenerator();
virtual const char* GetName() const
virtual std::string GetName() const
{ return cmExtraCodeLiteGenerator::GetActualName();}
static const char* GetActualName() { return "CodeLite";}
static std::string GetActualName() { return "CodeLite";}
static cmExternalMakefileProjectGenerator* New()
{ return new cmExtraCodeLiteGenerator; }
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
const char* fullName) const;
const std::string& fullName) const;
virtual void Generate();
void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
......
......@@ -45,7 +45,7 @@ cmExtraEclipseCDT4Generator
//----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator
::GetDocumentation(cmDocumentationEntry& entry, const char*) const
::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates Eclipse CDT 4.0 project files.";
......
......@@ -33,14 +33,14 @@ public:
return new cmExtraEclipseCDT4Generator;
}
virtual const char* GetName() const {
virtual std::string GetName() const {
return cmExtraEclipseCDT4Generator::GetActualName();
}
static const char* GetActualName() { return "Eclipse CDT4"; }
static std::string GetActualName() { return "Eclipse CDT4"; }
virtual void GetDocumentation(cmDocumentationEntry& entry,
const char* fullName) const;
const std::string& fullName) const;
virtual void EnableLanguage(std::vector<std::string> const& languages,
cmMakefile *, bool optional);
......
......@@ -25,7 +25,7 @@
//----------------------------------------------------------------------------
void cmExtraKateGenerator
::GetDocumentation(cmDocumentationEntry& entry, const char*) const
::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates Kate project files.";
......@@ -52,7 +52,7 @@ void cmExtraKateGenerator::Generate()
this->ProjectName = this->GenerateProjectName(mf->GetProjectName(),
mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
this->GetPathBasename(mf->GetHomeOutputDirectory()));
this->UseNinja = (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0);
this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja");
this->CreateKateProjectFile(mf);
this->CreateDummyKateProjectFile(mf);
......
......@@ -28,14 +28,14 @@ class cmExtraKateGenerator : public cmExternalMakefileProjectGenerator
public:
cmExtraKateGenerator();
virtual const char* GetName() const
virtual std::string GetName() const
{ return cmExtraKateGenerator::GetActualName();}
static const char* GetActualName() { return "Kate";}
static std::string GetActualName() { return "Kate";}
static cmExternalMakefileProjectGenerator* New()
{ return new cmExtraKateGenerator; }
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
const char* fullName) const;
const std::string& fullName) const;
virtual void Generate();
private:
......
......@@ -41,7 +41,7 @@ http://sublimetext.info/docs/en/reference/build_systems.html
//----------------------------------------------------------------------------
void cmExtraSublimeTextGenerator
::GetDocumentation(cmDocumentationEntry& entry, const char*) const
::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates Sublime Text 2 project files.";
......@@ -290,7 +290,7 @@ void cmExtraSublimeTextGenerator::
// Ninja uses ninja.build files (look for a way to get the output file name
// from cmMakefile or something)
std::string makefileName;
if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
if (this->GlobalGenerator->GetName() == "Ninja")
{
makefileName = "build.ninja";
}
......@@ -320,7 +320,8 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
{
std::string command = "\"";
command += make + "\"";
if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)
std::string generator = this->GlobalGenerator->GetName();
if (generator == "NMake Makefiles")
{
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
command += ", \"/NOLOGO\", \"/f\", \"";
......@@ -329,7 +330,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
command += target;
command += "\"";
}
else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
else if (generator == "Ninja")
{
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
command += ", \"-f\", \"";
......@@ -341,7 +342,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
else
{
std::string makefileName;
if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
if (generator == "MinGW Makefiles")
{
// no escaping of spaces in this case, see
// http://public.kitware.com/Bug/view.php?id=10014
......
......@@ -31,15 +31,15 @@ public:
typedef std::map<std::string, std::vector<std::string> > MapSourceFileFlags;
cmExtraSublimeTextGenerator();
virtual const char* GetName() const
virtual std::string GetName() const
{ return cmExtraSublimeTextGenerator::GetActualName();}
static const char* GetActualName()
static std::string GetActualName()
{ return "Sublime Text 2";}
static cmExternalMakefileProjectGenerator* New()
{ return new cmExtraSublimeTextGenerator; }
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
const char* fullName) const;
const std::string& fullName) const;
virtual void Generate();
private:
......
......@@ -28,9 +28,9 @@ public:
<cmGlobalBorlandMakefileGenerator>(); }
///! Get the name for the generator.
virtual const char* GetName() const {
virtual std::string GetName() const {
return cmGlobalBorlandMakefileGenerator::GetActualName();}
static const char* GetActualName() {return "Borland Makefiles";}
static std::string GetActualName() {return "Borland Makefiles";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
......
......@@ -2599,9 +2599,9 @@ void cmGlobalGenerator::SetExternalMakefileProjectGenerator(
}
}
const char* cmGlobalGenerator::GetExtraGeneratorName() const
std::string cmGlobalGenerator::GetExtraGeneratorName() const
{
return this->ExtraGenerator==0 ? 0 : this->ExtraGenerator->GetName();
return this->ExtraGenerator? this->ExtraGenerator->GetName() : std::string();
}
void cmGlobalGenerator::FileReplacedDuringGenerate(const std::string& filename)
......
......@@ -51,11 +51,11 @@ public:
virtual cmLocalGenerator *CreateLocalGenerator();
///! Get the name for this generator
virtual const char *GetName() const { return "Generic"; };
virtual std::string GetName() const { return "Generic"; };
/** Check whether the given name matches the current generator. */
virtual bool MatchesGeneratorName(const char* name) const
{ return strcmp(this->GetName(), name) == 0; }
virtual bool MatchesGeneratorName(const std::string& name) const
{ return this->GetName() == name; }
/** Set the generator-specific toolset name. Returns true if toolset
is supported and false otherwise. */
......@@ -163,7 +163,7 @@ public:
void SetExternalMakefileProjectGenerator(
cmExternalMakefileProjectGenerator *extraGenerator);
const char* GetExtraGeneratorName() const;
std::string GetExtraGeneratorName() const;
void AddInstallComponent(const char* component);
......
......@@ -29,7 +29,8 @@ public:
virtual ~cmGlobalGeneratorFactory() {}
/** Create a GlobalGenerator */
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* n) const = 0;
virtual cmGlobalGenerator* CreateGlobalGenerator(
const std::string& n) const = 0;
/** Get the documentation entry for this factory */
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
......@@ -43,8 +44,9 @@ class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
{
public:
/** Create a GlobalGenerator */
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
if (strcmp(name, T::GetActualName())) return 0;
virtual cmGlobalGenerator* CreateGlobalGenerator(
const std::string& name) const {
if (name != T::GetActualName()) return 0;
return new T; }
/** Get the documentation entry for this factory */
......
......@@ -27,11 +27,11 @@ public:
return new cmGlobalGeneratorSimpleFactory
<cmGlobalJOMMakefileGenerator>(); }
///! Get the name for the generator.
virtual const char* GetName() const {
virtual std::string GetName() const {
return cmGlobalJOMMakefileGenerator::GetActualName();}
// use NMake Makefiles in the name so that scripts/tests that depend on the
// name NMake Makefiles will work
static const char* GetActualName() {return "NMake Makefiles JOM";}
static std::string GetActualName() {return "NMake Makefiles JOM";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
......
......@@ -25,7 +25,7 @@
//----------------------------------------------------------------------------
void cmGlobalKdevelopGenerator
::GetDocumentation(cmDocumentationEntry& entry, const char*) const
::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates KDevelop 3 project files.";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment