From 1a1b737c99ac0bd0d555fde2fadf77f08516a4ea Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 24 Feb 2014 17:36:27 -0500 Subject: [PATCH] stringapi: Use strings for generator names --- Source/CTest/cmCTestBuildCommand.cxx | 3 +- Source/cmComputeLinkInformation.cxx | 5 ++-- Source/cmExternalMakefileProjectGenerator.cxx | 22 +++++++------- Source/cmExternalMakefileProjectGenerator.h | 11 +++---- Source/cmExtraCodeBlocksGenerator.cxx | 9 +++--- Source/cmExtraCodeBlocksGenerator.h | 6 ++-- Source/cmExtraCodeLiteGenerator.cxx | 2 +- Source/cmExtraCodeLiteGenerator.h | 6 ++-- Source/cmExtraEclipseCDT4Generator.cxx | 2 +- Source/cmExtraEclipseCDT4Generator.h | 6 ++-- Source/cmExtraKateGenerator.cxx | 4 +-- Source/cmExtraKateGenerator.h | 6 ++-- Source/cmExtraSublimeTextGenerator.cxx | 11 +++---- Source/cmExtraSublimeTextGenerator.h | 6 ++-- Source/cmGlobalBorlandMakefileGenerator.h | 4 +-- Source/cmGlobalGenerator.cxx | 4 +-- Source/cmGlobalGenerator.h | 8 ++--- Source/cmGlobalGeneratorFactory.h | 8 +++-- Source/cmGlobalJOMMakefileGenerator.h | 4 +-- Source/cmGlobalKdevelopGenerator.cxx | 2 +- Source/cmGlobalKdevelopGenerator.h | 6 ++-- Source/cmGlobalMSYSMakefileGenerator.h | 4 +-- Source/cmGlobalMinGWMakefileGenerator.h | 4 +-- Source/cmGlobalNMakeMakefileGenerator.h | 4 +-- Source/cmGlobalNinjaGenerator.h | 4 +-- Source/cmGlobalUnixMakefileGenerator3.cxx | 4 +-- Source/cmGlobalUnixMakefileGenerator3.h | 4 +-- Source/cmGlobalVisualStudio10Generator.cxx | 24 ++++++++------- Source/cmGlobalVisualStudio10Generator.h | 7 +++-- Source/cmGlobalVisualStudio11Generator.cxx | 24 ++++++++------- Source/cmGlobalVisualStudio11Generator.h | 7 +++-- Source/cmGlobalVisualStudio12Generator.cxx | 24 ++++++++------- Source/cmGlobalVisualStudio12Generator.h | 7 +++-- Source/cmGlobalVisualStudio6Generator.h | 4 +-- Source/cmGlobalVisualStudio71Generator.cxx | 9 +++--- Source/cmGlobalVisualStudio71Generator.h | 8 ++--- Source/cmGlobalVisualStudio7Generator.cxx | 22 ++++++++------ Source/cmGlobalVisualStudio7Generator.h | 10 +++---- Source/cmGlobalVisualStudio8Generator.cxx | 29 +++++++++++-------- Source/cmGlobalVisualStudio8Generator.h | 9 +++--- Source/cmGlobalVisualStudio9Generator.cxx | 14 +++++---- Source/cmGlobalVisualStudio9Generator.h | 5 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 4 +-- Source/cmGlobalVisualStudioGenerator.h | 2 +- Source/cmGlobalWatcomWMakeGenerator.h | 4 +-- Source/cmGlobalXCodeGenerator.cxx | 7 +++-- Source/cmGlobalXCodeGenerator.h | 4 +-- Source/cmLocalVisualStudio7Generator.h | 2 +- Source/cmMakefile.cxx | 4 +-- Source/cmQtAutoGenerators.cxx | 2 +- Source/cmake.cxx | 16 +++++----- Source/cmake.h | 4 +-- 52 files changed, 221 insertions(+), 190 deletions(-) diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index c60ded065..04eabd20d 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -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; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e4e204738..62eaec235 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -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())) diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx index 0d42c3595..d89a1c83c 100644 --- a/Source/cmExternalMakefileProjectGenerator.cxx +++ b/Source/cmExternalMakefileProjectGenerator.cxx @@ -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 ""; } diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h index bce441dba..cba1c76dd 100644 --- a/Source/cmExternalMakefileProjectGenerator.h +++ b/Source/cmExternalMakefileProjectGenerator.h @@ -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 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; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 01d115505..4a5970492 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -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; diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index 1cbc3f35f..0435ad8c9 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -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: diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 1e34fe043..15fe8bbf2 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -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."; diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h index 984313e0b..6b4965d5a 100644 --- a/Source/cmExtraCodeLiteGenerator.h +++ b/Source/cmExtraCodeLiteGenerator.h @@ -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& lgs); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 38a247034..4aabc7e20 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -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."; diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index d88b24774..ef99760e5 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -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 const& languages, cmMakefile *, bool optional); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index a0d37d4ef..567542e31 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -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); diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index 6ced5fe0a..f800febe8 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -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: diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 03c7c9297..f973a844c 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -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 diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index 44dfb3194..4173b7de3 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -31,15 +31,15 @@ public: typedef std::map > 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: diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 70004ea3a..470dea43e 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -28,9 +28,9 @@ public: (); } ///! 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); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index c1cce2ed6..5dee5d707 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -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) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 761fb0760..38dc63aba 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -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); diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h index fd1d65fb5..3c2cd6042 100644 --- a/Source/cmGlobalGeneratorFactory.h +++ b/Source/cmGlobalGeneratorFactory.h @@ -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 */ diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 28893bf27..344e01343 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -27,11 +27,11 @@ public: return new cmGlobalGeneratorSimpleFactory (); } ///! 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); diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 2d485f658..71e08cc1a 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -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."; diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h index a1ad39d44..0d59fc578 100644 --- a/Source/cmGlobalKdevelopGenerator.h +++ b/Source/cmGlobalKdevelopGenerator.h @@ -33,14 +33,14 @@ class cmGlobalKdevelopGenerator : public cmExternalMakefileProjectGenerator public: cmGlobalKdevelopGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmGlobalKdevelopGenerator::GetActualName();} - static const char* GetActualName() { return "KDevelop3";} + static std::string GetActualName() { return "KDevelop3";} static cmExternalMakefileProjectGenerator* New() { return new cmGlobalKdevelopGenerator; } /** 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: diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h index 659de1186..c4825bdd1 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.h +++ b/Source/cmGlobalMSYSMakefileGenerator.h @@ -28,9 +28,9 @@ public: (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalMSYSMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "MSYS Makefiles";} + static std::string GetActualName() {return "MSYS Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h index 7951e9886..428942235 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.h +++ b/Source/cmGlobalMinGWMakefileGenerator.h @@ -27,9 +27,9 @@ public: return new cmGlobalGeneratorSimpleFactory (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalMinGWMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "MinGW Makefiles";} + static std::string GetActualName() {return "MinGW Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index 5756fbd0d..2ff44e370 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -27,9 +27,9 @@ public: return new cmGlobalGeneratorSimpleFactory (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalNMakeMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "NMake Makefiles";} + static std::string GetActualName() {return "NMake Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 4a284864a..2467af9c7 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -173,11 +173,11 @@ public: virtual cmLocalGenerator* CreateLocalGenerator(); /// Overloaded methods. @see cmGlobalGenerator::GetName(). - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalNinjaGenerator::GetActualName(); } /// @return the name of this generator. - static const char* GetActualName() { return "Ninja"; } + static std::string GetActualName() { return "Ninja"; } /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 9ddbe5b45..08a1c6205 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -72,7 +72,7 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const { // If generating for an extra IDE, the edit_cache target cannot // launch a terminal-interactive tool, so always use cmake-gui. - if(this->GetExtraGeneratorName()) + if(!this->GetExtraGeneratorName().empty()) { return cmSystemTools::GetCMakeGUICommand(); } @@ -579,7 +579,7 @@ void cmGlobalUnixMakefileGenerator3 // Since we have full control over the invocation of nmake, let us // make it quiet. - if ( strcmp(this->GetName(), "NMake Makefiles") == 0 ) + if ( this->GetName() == "NMake Makefiles" ) { makeCommand.push_back("/NOLOGO"); } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index d64afaf6f..ea2b6c045 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -60,9 +60,9 @@ public: (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalUnixMakefileGenerator3::GetActualName();} - static const char* GetActualName() {return "Unix Makefiles";} + static std::string GetActualName() {return "Unix Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 3819a5be6..2dc658eae 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -21,13 +21,14 @@ static const char vs10generatorName[] = "Visual Studio 10 2010"; // Map generator name without year to name with year. -static const char* cmVS10GenName(const char* name, std::string& genName) +static const char* cmVS10GenName(const std::string& name, std::string& genName) { - if(strncmp(name, vs10generatorName, sizeof(vs10generatorName)-6) != 0) + if(strncmp(name.c_str(), vs10generatorName, + sizeof(vs10generatorName)-6) != 0) { return 0; } - const char* p = name + sizeof(vs10generatorName) - 6; + const char* p = name.c_str() + sizeof(vs10generatorName) - 6; if(cmHasLiteralPrefix(p, " 2010")) { p += 5; @@ -40,27 +41,27 @@ class cmGlobalVisualStudio10Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { std::string genName; const char* p = cmVS10GenName(name, genName); if(!p) { return 0; } - name = genName.c_str(); if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio10Generator( - name, NULL, NULL); + genName, "", ""); } if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio10Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64", "CMAKE_FORCE_WIN64"); } if(strcmp(p, " IA64") == 0) { return new cmGlobalVisualStudio10Generator( - name, "Itanium", "CMAKE_FORCE_IA64"); + genName, "Itanium", "CMAKE_FORCE_IA64"); } return 0; } @@ -87,8 +88,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { @@ -102,7 +103,8 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const +cmGlobalVisualStudio10Generator::MatchesGeneratorName( + const std::string& name) const { std::string genName; if(cmVS10GenName(name, genName)) diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 5d902eedb..d3ad69e51 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -24,11 +24,12 @@ class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator { public: - cmGlobalVisualStudio10Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio10Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); - virtual bool MatchesGeneratorName(const char* name) const; + virtual bool MatchesGeneratorName(const std::string& name) const; virtual bool SetGeneratorToolset(std::string const& ts); diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 1f0c47a35..4caa7f2b3 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -16,13 +16,14 @@ static const char vs11generatorName[] = "Visual Studio 11 2012"; // Map generator name without year to name with year. -static const char* cmVS11GenName(const char* name, std::string& genName) +static const char* cmVS11GenName(const std::string& name, std::string& genName) { - if(strncmp(name, vs11generatorName, sizeof(vs11generatorName)-6) != 0) + if(strncmp(name.c_str(), vs11generatorName, + sizeof(vs11generatorName)-6) != 0) { return 0; } - const char* p = name + sizeof(vs11generatorName) - 6; + const char* p = name.c_str() + sizeof(vs11generatorName) - 6; if(cmHasLiteralPrefix(p, " 2012")) { p += 5; @@ -35,27 +36,27 @@ class cmGlobalVisualStudio11Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { std::string genName; const char* p = cmVS11GenName(name, genName); if(!p) { return 0; } - name = genName.c_str(); if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio11Generator( - name, NULL, NULL); + genName, "", ""); } if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio11Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64", "CMAKE_FORCE_WIN64"); } if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio11Generator( - name, "ARM", NULL); + genName, "ARM", ""); } if(*p++ != ' ') @@ -107,8 +108,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio10Generator(name, platformName, additionalPlatformDefinition) { @@ -121,7 +122,8 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio11Generator::MatchesGeneratorName(const char* name) const +cmGlobalVisualStudio11Generator::MatchesGeneratorName( + const std::string& name) const { std::string genName; if(cmVS11GenName(name, genName)) diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 7ef77e7cc..48ea4891d 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -20,11 +20,12 @@ class cmGlobalVisualStudio11Generator: public cmGlobalVisualStudio10Generator { public: - cmGlobalVisualStudio11Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio11Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); - virtual bool MatchesGeneratorName(const char* name) const; + virtual bool MatchesGeneratorName(const std::string& name) const; virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 3074794b8..6cd9f1235 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -16,13 +16,14 @@ static const char vs12generatorName[] = "Visual Studio 12 2013"; // Map generator name without year to name with year. -static const char* cmVS12GenName(const char* name, std::string& genName) +static const char* cmVS12GenName(const std::string& name, std::string& genName) { - if(strncmp(name, vs12generatorName, sizeof(vs12generatorName)-6) != 0) + if(strncmp(name.c_str(), vs12generatorName, + sizeof(vs12generatorName)-6) != 0) { return 0; } - const char* p = name + sizeof(vs12generatorName) - 6; + const char* p = name.c_str() + sizeof(vs12generatorName) - 6; if(cmHasLiteralPrefix(p, " 2013")) { p += 5; @@ -35,27 +36,27 @@ class cmGlobalVisualStudio12Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { std::string genName; const char* p = cmVS12GenName(name, genName); if(!p) { return 0; } - name = genName.c_str(); if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio12Generator( - name, NULL, NULL); + genName, "", ""); } if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio12Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64", "CMAKE_FORCE_WIN64"); } if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio12Generator( - name, "ARM", NULL); + genName, "ARM", ""); } return 0; } @@ -82,8 +83,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio11Generator(name, platformName, additionalPlatformDefinition) { @@ -96,7 +97,8 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio12Generator::MatchesGeneratorName(const char* name) const +cmGlobalVisualStudio12Generator::MatchesGeneratorName( + const std::string& name) const { std::string genName; if(cmVS12GenName(name, genName)) diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 5a4a78d0b..4557f28d0 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -20,11 +20,12 @@ class cmGlobalVisualStudio12Generator: public cmGlobalVisualStudio11Generator { public: - cmGlobalVisualStudio12Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio12Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); - virtual bool MatchesGeneratorName(const char* name) const; + virtual bool MatchesGeneratorName(const std::string& name) const; virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index eb3dddf97..14046f0c3 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -31,9 +31,9 @@ public: (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalVisualStudio6Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 6";} + static std::string GetActualName() {return "Visual Studio 6";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 08bcc5b71..4bea5acdd 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -17,7 +17,8 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator( - const char* platformName) : cmGlobalVisualStudio7Generator(platformName) + const std::string& platformName) + : cmGlobalVisualStudio7Generator(platformName) { this->ProjectConfigurationSectionName = "ProjectConfiguration"; } @@ -279,10 +280,10 @@ void cmGlobalVisualStudio71Generator ::WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType, const std::set& configsPartOfDefaultBuild, - const char* platformMapping) + std::string const& platformMapping) { - const char* platformName = - platformMapping ? platformMapping : this->GetPlatformName(); + const std::string& platformName = + !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); for(std::vector::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 75cc6aeb9..2b5259a76 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -23,15 +23,15 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator { public: - cmGlobalVisualStudio71Generator(const char* platformName = NULL); + cmGlobalVisualStudio71Generator(const std::string& platformName = ""); static cmGlobalGeneratorFactory* NewFactory() { return new cmGlobalGeneratorSimpleFactory (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalVisualStudio71Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 7 .NET 2003";} + static std::string GetActualName() {return "Visual Studio 7 .NET 2003";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -67,7 +67,7 @@ protected: virtual void WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, - const char* platformMapping = NULL); + const std::string& platformMapping = ""); virtual void WriteExternalProject(std::ostream& fout, const std::string& name, const char* path, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 392710049..03772ddf7 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -19,16 +19,19 @@ #include cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( - const char* platformName) + const std::string& platformName) { this->IntelProjectVersion = 0; this->DevEnvCommandInitialized = false; - if (!platformName) + if (platformName.empty()) { - platformName = "Win32"; + this->PlatformName = "Win32"; + } + else + { + this->PlatformName = platformName; } - this->PlatformName = platformName; } cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator() @@ -260,7 +263,7 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) { cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName()); + mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str()); mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", this->GetIntelProjectVersion()); } @@ -381,9 +384,10 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( { std::set allConfigurations(this->Configurations.begin(), this->Configurations.end()); + const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING"); this->WriteProjectConfigurations( fout, target->GetName().c_str(), target->GetType(), - allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING")); + allConfigurations, mapping ? mapping : ""); } else { @@ -732,10 +736,10 @@ void cmGlobalVisualStudio7Generator ::WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType, const std::set& configsPartOfDefaultBuild, - const char* platformMapping) + const std::string& platformMapping) { - const char* platformName = - platformMapping ? platformMapping : this->GetPlatformName(); + const std::string& platformName = + !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); for(std::vector::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index b65948036..9ab04626a 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -26,7 +26,7 @@ struct cmIDEFlagTable; class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator { public: - cmGlobalVisualStudio7Generator(const char* platformName = NULL); + cmGlobalVisualStudio7Generator(const std::string& platformName = ""); ~cmGlobalVisualStudio7Generator(); static cmGlobalGeneratorFactory* NewFactory() { @@ -34,12 +34,12 @@ public: (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalVisualStudio7Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 7";} + static std::string GetActualName() {return "Visual Studio 7";} ///! Get the name for the platform. - const char* GetPlatformName() const { return this->PlatformName.c_str(); } + const std::string& GetPlatformName() const { return this->PlatformName; } ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -131,7 +131,7 @@ protected: virtual void WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, - const char* platformMapping = NULL); + const std::string& platformMapping = ""); virtual void WriteSLNGlobalSections(std::ostream& fout, cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 2ae1bbc17..08c139734 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -23,17 +23,19 @@ class cmGlobalVisualStudio8Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(strstr(name, vs8generatorName) != name) + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { + if(strncmp(name.c_str(), vs8generatorName, + sizeof(vs8generatorName) - 1) != 0) { return 0; } - const char* p = name + sizeof(vs8generatorName) - 1; + const char* p = name.c_str() + sizeof(vs8generatorName) - 1; if(p[0] == '\0') { return new cmGlobalVisualStudio8Generator( - name, NULL, NULL); + name, "", ""); } if(p[0] != ' ') @@ -57,7 +59,7 @@ public: } cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator( - name, p, NULL); + name, p, ""); ret->WindowsCEVersion = parser.GetOSVersion(); return ret; } @@ -90,14 +92,14 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio71Generator(platformName) { this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->Name = name; - if (additionalPlatformDefinition) + if (!additionalPlatformDefinition.empty()) { this->AdditionalPlatformDefinition = additionalPlatformDefinition; } @@ -374,7 +376,7 @@ cmGlobalVisualStudio8Generator ::WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, - const char* platformMapping) + std::string const& platformMapping) { std::string guid = this->GetGUID(name); for(std::vector::iterator i = this->Configurations.begin(); @@ -382,7 +384,8 @@ cmGlobalVisualStudio8Generator { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|" - << (platformMapping ? platformMapping : this->GetPlatformName()) + << (!platformMapping.empty()? + platformMapping : this->GetPlatformName()) << "\n"; std::set::const_iterator ci = configsPartOfDefaultBuild.find(*i); @@ -390,7 +393,8 @@ cmGlobalVisualStudio8Generator { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|" - << (platformMapping ? platformMapping : this->GetPlatformName()) + << (!platformMapping.empty()? + platformMapping : this->GetPlatformName()) << "\n"; } bool needsDeploy = (type == cmTarget::EXECUTABLE || @@ -399,7 +403,8 @@ cmGlobalVisualStudio8Generator { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".Deploy.0 = " << *i << "|" - << (platformMapping ? platformMapping : this->GetPlatformName()) + << (!platformMapping.empty()? + platformMapping : this->GetPlatformName()) << "\n"; } } diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index bafb9eb90..2459c05a5 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -23,12 +23,13 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator { public: - cmGlobalVisualStudio8Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio8Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. - virtual const char* GetName() const {return this->Name.c_str();} + virtual std::string GetName() const {return this->Name;} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -81,7 +82,7 @@ protected: virtual void WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, - const char* platformMapping = NULL); + const std::string& platformMapping = ""); virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const std::string& name, diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index ccc27ad6f..c0051c723 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -22,17 +22,19 @@ class cmGlobalVisualStudio9Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(strstr(name, vs9generatorName) != name) + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { + if(strncmp(name.c_str(), vs9generatorName, + sizeof(vs9generatorName) - 1) != 0) { return 0; } - const char* p = name + sizeof(vs9generatorName) - 1; + const char* p = name.c_str() + sizeof(vs9generatorName) - 1; if(p[0] == '\0') { return new cmGlobalVisualStudio9Generator( - name, NULL, NULL); + name, "", ""); } if(p[0] != ' ') @@ -96,8 +98,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index 202aa8d12..fb87bbefa 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -24,8 +24,9 @@ class cmGlobalVisualStudio9Generator : public cmGlobalVisualStudio8Generator { public: - cmGlobalVisualStudio9Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio9Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b2a705ecc..69c893cc8 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -22,7 +22,7 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() { - this->AdditionalPlatformDefinition = NULL; + this->AdditionalPlatformDefinition = ""; } //---------------------------------------------------------------------------- @@ -518,7 +518,7 @@ void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf) //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) { - if(this->AdditionalPlatformDefinition) + if(!this->AdditionalPlatformDefinition.empty()) { mf->AddDefinition(this->AdditionalPlatformDefinition, "TRUE"); } diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index dc0f9c71e..7e8dcf8b7 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -110,7 +110,7 @@ protected: std::string GetUtilityDepend(cmTarget const* target); typedef std::map UtilityDependsMap; UtilityDependsMap UtilityDepends; - const char* AdditionalPlatformDefinition; + std::string AdditionalPlatformDefinition; private: virtual std::string GetVSMakeProgram() = 0; diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index d5350efd1..2057a4295 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -27,9 +27,9 @@ public: return new cmGlobalGeneratorSimpleFactory (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalWatcomWMakeGenerator::GetActualName();} - static const char* GetActualName() {return "Watcom WMake";} + static std::string GetActualName() {return "Watcom WMake";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e1f2a919a..30bded536 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -116,7 +116,8 @@ public: class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const; + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const; virtual void GetDocumentation(cmDocumentationEntry& entry) const { cmGlobalXCodeGenerator::GetDocumentation(entry); } @@ -152,9 +153,9 @@ cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory() //---------------------------------------------------------------------------- cmGlobalGenerator* cmGlobalXCodeGenerator::Factory -::CreateGlobalGenerator(const char* name) const +::CreateGlobalGenerator(const std::string& name) const { - if (strcmp(name, GetActualName())) + if (name != GetActualName()) return 0; #if defined(CMAKE_BUILD_WITH_CMAKE) cmXcodeVersionParser parser; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index aec795841..54c6f965c 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -33,9 +33,9 @@ public: static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalXCodeGenerator::GetActualName();} - static const char* GetActualName() {return "Xcode";} + static std::string GetActualName() {return "Xcode";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index d2e66a5c9..6c045594a 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -53,7 +53,7 @@ public: */ void SetBuildType(BuildType,const std::string& name); - void SetPlatformName(const char* n) { this->PlatformName = n;} + void SetPlatformName(const std::string& n) { this->PlatformName = n;} void SetExtraFlagTable(cmVS7FlagTable const* table) { this->ExtraFlagTable = table; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e61b12bf4..e8be29fe0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1378,8 +1378,8 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) // VS6 IDE does not support definition values with spaces in // combination with '"', '$', or ';'. - if((strcmp(this->LocalGenerator->GetGlobalGenerator()->GetName(), - "Visual Studio 6") == 0) && + if((this->LocalGenerator->GetGlobalGenerator()->GetName() == + "Visual Studio 6") && (def.find(" ") != def.npos && def.find_first_of("\"$;") != def.npos)) { return false; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 48a6b38e3..c32f62480 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -251,7 +251,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) bool usePRE_BUILD = false; cmLocalGenerator* localGen = makefile->GetLocalGenerator(); cmGlobalGenerator* gg = localGen->GetGlobalGenerator(); - if(strstr(gg->GetName(), "Visual Studio")) + if(gg->GetName().find("Visual Studio") != std::string::npos) { cmLocalVisualStudioGenerator* vslg = static_cast(localGen); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 13572f418..abe27a5e9 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -965,7 +965,7 @@ int cmake::AddCMakePaths() return 1; } -void cmake::AddExtraGenerator(const char* name, +void cmake::AddExtraGenerator(const std::string& name, CreateExtraGeneratorFunctionType newFunction) { cmExternalMakefileProjectGenerator* extraGenerator = newFunction(); @@ -1034,9 +1034,10 @@ void cmake::GetRegisteredGenerators(std::vector& names) } } -cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) +cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname) { cmExternalMakefileProjectGenerator* extraGenerator = 0; + std::string name = gname; RegisteredExtraGeneratorsMap::const_iterator extraGenIt = this->ExtraGenerators.find(name); if (extraGenIt != this->ExtraGenerators.end()) @@ -1324,7 +1325,8 @@ int cmake::ActualConfigure() if(genName) { std::string fullName = cmExternalMakefileProjectGenerator:: - CreateFullGeneratorName(genName, extraGenName); + CreateFullGeneratorName(genName, + extraGenName ? extraGenName : ""); this->GlobalGenerator = this->CreateGlobalGenerator(fullName.c_str()); } if(this->GlobalGenerator) @@ -1417,13 +1419,13 @@ int cmake::ActualConfigure() if(!this->CacheManager->GetCacheValue("CMAKE_GENERATOR")) { this->CacheManager->AddCacheEntry("CMAKE_GENERATOR", - this->GlobalGenerator->GetName(), + this->GlobalGenerator->GetName().c_str(), "Name of generator.", cmCacheManager::INTERNAL); this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR", - this->GlobalGenerator->GetExtraGeneratorName(), - "Name of external makefile project generator.", - cmCacheManager::INTERNAL); + this->GlobalGenerator->GetExtraGeneratorName().c_str(), + "Name of external makefile project generator.", + cmCacheManager::INTERNAL); } if(const char* tsName = diff --git a/Source/cmake.h b/Source/cmake.h index 933502a26..3134493a4 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -175,7 +175,7 @@ class cmake void PreLoadCMakeFiles(); ///! Create a GlobalGenerator - cmGlobalGenerator* CreateGlobalGenerator(const char* name); + cmGlobalGenerator* CreateGlobalGenerator(const std::string& name); ///! Return the global generator assigned to this instance of cmake cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; } @@ -380,7 +380,7 @@ protected: void AddDefaultCommands(); void AddDefaultGenerators(); void AddDefaultExtraGenerators(); - void AddExtraGenerator(const char* name, + void AddExtraGenerator(const std::string& name, CreateExtraGeneratorFunctionType newFunction); cmPolicies *Policies;