diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 7fe47c3e4..5fff0fb27 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -399,7 +399,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, lg->GetIncludeDirectories(includes, gtgt, language, config); std::string includeFlags = lg->GetIncludeFlags(includes, gtgt, language, true); // full include paths - lg->AppendFlags(flags, includeFlags.c_str()); + lg->AppendFlags(flags, includeFlags); } // Append old-style preprocessor definition flags. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index f375b5f3c..6b1672110 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2200,7 +2200,7 @@ static void AddVisibilityCompileOption(std::string &flags, cmTarget* target, return; } std::string option = std::string(opt) + prop; - lg->AppendFlags(flags, option.c_str()); + lg->AppendFlags(flags, option); } static void AddInlineVisibilityCompileOption(std::string &flags, @@ -2384,11 +2384,10 @@ void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AppendFlags(std::string& flags, - const char* newFlags) + const std::string& newFlags) { - if(newFlags && *newFlags) + if(!newFlags.empty()) { - std::string newf = newFlags; if(flags.size()) { flags += " "; @@ -2397,11 +2396,21 @@ void cmLocalGenerator::AppendFlags(std::string& flags, } } +//---------------------------------------------------------------------------- +void cmLocalGenerator::AppendFlags(std::string& flags, + const char* newFlags) +{ + if(newFlags && *newFlags) + { + this->AppendFlags(flags, std::string(newFlags)); + } +} + //---------------------------------------------------------------------------- void cmLocalGenerator::AppendFlagEscape(std::string& flags, const std::string& rawFlag) { - this->AppendFlags(flags, this->EscapeForShell(rawFlag).c_str()); + this->AppendFlags(flags, this->EscapeForShell(rawFlag)); } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index cf754aad6..32da21b75 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -152,6 +152,7 @@ public: void AddCompilerRequirementFlag(std::string &flags, cmTarget* target, const std::string& lang); ///! Append flags to a string. + virtual void AppendFlags(std::string& flags, const std::string& newFlags); virtual void AppendFlags(std::string& flags, const char* newFlags); virtual void AppendFlagEscape(std::string& flags, const std::string& rawFlag); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 7ffe84d83..94e45e5b7 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -956,21 +956,28 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags, - const char* newFlags) + const std::string& newFlags) { - if(this->WatcomWMake && newFlags && *newFlags) + if(this->WatcomWMake && !newFlags.empty()) { std::string newf = newFlags; if(newf.find("\\\"") != newf.npos) { cmSystemTools::ReplaceString(newf, "\\\"", "\""); - this->cmLocalGenerator::AppendFlags(flags, newf.c_str()); + this->cmLocalGenerator::AppendFlags(flags, newf); return; } } this->cmLocalGenerator::AppendFlags(flags, newFlags); } +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags, + const char* newFlags) +{ + this->cmLocalGenerator::AppendFlags(flags, newFlags); +} + //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 99974eef7..4f2e4a035 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -168,6 +168,7 @@ public: const std::string& tgt); // append flags to a string + virtual void AppendFlags(std::string& flags, const std::string& newFlags); virtual void AppendFlags(std::string& flags, const char* newFlags); // append an echo command diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7ac025687..80473f613 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -249,7 +249,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Create set of linking flags. std::string linkFlags; - this->LocalGenerator->AppendFlags(linkFlags, extraFlags.c_str()); + this->LocalGenerator->AppendFlags(linkFlags, extraFlags); // Add OSX version flags, if any. if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || @@ -810,6 +810,6 @@ cmMakefileLibraryTargetGenerator // Append the flag since a non-zero version is specified. cmOStringStream vflag; vflag << flag << major << "." << minor << "." << patch; - this->LocalGenerator->AppendFlags(flags, vflag.str().c_str()); + this->LocalGenerator->AppendFlags(flags, vflag.str()); } } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d4723adb3..73d24a929 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -303,7 +303,7 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) // Add include directory flags. this->LocalGenerator-> - AppendFlags(flags,this->GetFrameworkFlags(l).c_str()); + AppendFlags(flags,this->GetFrameworkFlags(l)); // Add target-specific flags. this->LocalGenerator->AddCompileOptions(flags, this->Target, @@ -551,7 +551,7 @@ cmMakefileTargetGenerator std::string langFlags = "$("; langFlags += lang; langFlags += "_FLAGS)"; - this->LocalGenerator->AppendFlags(flags, langFlags.c_str()); + this->LocalGenerator->AppendFlags(flags, langFlags); std::string configUpper = cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName); @@ -1968,11 +1968,11 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, std::string arg = "@" + this->CreateResponseFile(name.c_str(), includeFlags, this->FlagFileDepends[lang]); - this->LocalGenerator->AppendFlags(flags, arg.c_str()); + this->LocalGenerator->AppendFlags(flags, arg); } else { - this->LocalGenerator->AppendFlags(flags, includeFlags.c_str()); + this->LocalGenerator->AppendFlags(flags, includeFlags); } } @@ -2044,7 +2044,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) modflag += this->Convert(mod_dir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); - this->LocalGenerator->AppendFlags(flags, modflag.c_str()); + this->LocalGenerator->AppendFlags(flags, modflag); } // If there is a separate module path flag then duplicate the @@ -2066,7 +2066,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) flg += this->Convert(*idi, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); - this->LocalGenerator->AppendFlags(flags, flg.c_str()); + this->LocalGenerator->AppendFlags(flags, flg); } } } @@ -2093,7 +2093,7 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) // vs6's "cl -link" pass it to the linker. std::string flag = defFileFlag; flag += (this->LocalGenerator->ConvertToLinkReference(def)); - this->LocalGenerator->AppendFlags(flags, flag.c_str()); + this->LocalGenerator->AppendFlags(flags, flag); } //---------------------------------------------------------------------------- diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 358fb51a2..b95c4889d 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -169,7 +169,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, if(cmGlobalNinjaGenerator::IsMinGW()) cmSystemTools::ReplaceString(includeFlags, "\\", "/"); - this->LocalGenerator->AppendFlags(languageFlags, includeFlags.c_str()); + this->LocalGenerator->AppendFlags(languageFlags, includeFlags); // Append old-style preprocessor definition flags. this->LocalGenerator->AppendFlags(languageFlags, @@ -698,7 +698,7 @@ cmNinjaTargetGenerator std::string flag = defFileFlag; flag += (this->LocalGenerator->ConvertToLinkReference( this->ModuleDefinitionFile)); - this->LocalGenerator->AppendFlags(flags, flag.c_str()); + this->LocalGenerator->AppendFlags(flags, flag); } void