diff options
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 241 |
1 files changed, 126 insertions, 115 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b86a956..761db48 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -280,7 +280,7 @@ void cmLocalGenerator::GenerateTestFiles() // Compute the set of configurations. std::vector<std::string> configurationTypes; - const char* config = + const std::string& config = this->Makefile->GetConfigurations(configurationTypes, false); std::string file = this->Makefile->GetStartOutputDirectory(); @@ -384,11 +384,11 @@ void cmLocalGenerator::GenerateInstallRules() // Compute the set of configurations. std::vector<std::string> configurationTypes; - const char* config = + const std::string& config = this->Makefile->GetConfigurations(configurationTypes, false); // Choose a default install configuration. - const char* default_config = config; + const char* default_config = config.c_str(); const char* default_order[] = {"RELEASE", "MINSIZEREL", "RELWITHDEBINFO", "DEBUG", 0}; for(const char** c = default_order; *c && !default_config; ++c) @@ -557,7 +557,7 @@ void cmLocalGenerator::GenerateTargetManifest() } if(configNames.empty()) { - target.GenerateTargetManifest(0); + target.GenerateTargetManifest(""); } else { @@ -572,7 +572,7 @@ void cmLocalGenerator::GenerateTargetManifest() } void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, - const char* lang, + const std::string& lang, cmSourceFile& source, cmGeneratorTarget& target) { @@ -604,7 +604,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, std::vector<std::string> commands; cmSystemTools::ExpandList(rules, commands); cmLocalGenerator::RuleVariables vars; - vars.Language = lang; + vars.Language = lang.c_str(); vars.Source = sourceFile.c_str(); vars.Object = objectFile.c_str(); vars.ObjectDir = objectDir.c_str(); @@ -617,8 +617,8 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, // Parse the string to get the custom command line. cmCustomCommandLine commandLine; - std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str()); - for(std::vector<cmStdString>::iterator a = cmd.begin(); + std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str()); + for(std::vector<std::string>::iterator a = cmd.begin(); a != cmd.end(); ++a) { commandLine.push_back(*a); @@ -653,10 +653,10 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, ); } -void cmLocalGenerator::AddBuildTargetRule(const char* llang, +void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, cmGeneratorTarget& target) { - cmStdString objs; + std::string objs; std::vector<std::string> objVector; // Add all the sources outputs to the depends of the target std::vector<cmSourceFile*> classes; @@ -703,7 +703,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, &target); linkLibs = frameworkPath + linkPath + linkLibs; cmLocalGenerator::RuleVariables vars; - vars.Language = llang; + vars.Language = llang.c_str(); vars.Objects = objs.c_str(); vars.ObjectDir = "."; vars.Target = targetName.c_str(); @@ -712,8 +712,8 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, vars.LinkFlags = linkFlags.c_str(); std::string langFlags; - this->AddLanguageFlags(langFlags, llang, 0); - this->AddArchitectureFlags(langFlags, &target, llang, 0); + this->AddLanguageFlags(langFlags, llang, ""); + this->AddArchitectureFlags(langFlags, &target, llang, ""); vars.LanguageCompileFlags = langFlags.c_str(); cmCustomCommandLines commandLines; @@ -728,8 +728,8 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, this->ExpandRuleVariables(*i, vars); // Parse the string to get the custom command line. cmCustomCommandLine commandLine; - std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str()); - for(std::vector<cmStdString>::iterator a = cmd.begin(); + std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str()); + for(std::vector<std::string>::iterator a = cmd.begin(); a != cmd.end(); ++a) { commandLine.push_back(*a); @@ -747,7 +747,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, this->Makefile->AddCustomCommandToOutput( targetFullPath.c_str(), objVector, - 0, + "", commandLines, comment.c_str(), this->Makefile->GetStartOutputDirectory() @@ -758,7 +758,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, void cmLocalGenerator -::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang) +::CreateCustomTargetsAndCommands(std::set<std::string> const& lang) { cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator l = tgts.begin(); @@ -776,12 +776,12 @@ void cmLocalGenerator case cmTarget::MODULE_LIBRARY: case cmTarget::EXECUTABLE: { - const char* llang = target.Target->GetLinkerLanguage(); - if(!llang) + std::string llang = target.Target->GetLinkerLanguage(); + if(llang.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.Target->GetName()); + target.Target->GetName().c_str()); return; } // if the language is not in the set lang then create custom @@ -1156,8 +1156,11 @@ void cmLocalGenerator::ExpandRuleVariables(std::string& s, const RuleVariables& replaceValues) { - this->InsertRuleLauncher(s, replaceValues.CMTarget, - replaceValues.RuleLauncher); + if(replaceValues.RuleLauncher) + { + this->InsertRuleLauncher(s, replaceValues.CMTarget, + replaceValues.RuleLauncher); + } std::string::size_type start = s.find('<'); // no variables to expand if(start == s.npos) @@ -1201,7 +1204,7 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s, //---------------------------------------------------------------------------- const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, - const char* prop) + const std::string& prop) { if(target) { @@ -1215,7 +1218,7 @@ const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, //---------------------------------------------------------------------------- void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, - const char* prop) + const std::string& prop) { if(const char* val = this->GetRuleLauncher(target, prop)) { @@ -1227,7 +1230,7 @@ void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, +cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote, std::string const& result, OutputFormat format) { @@ -1235,10 +1238,10 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, // already exists, we can use a short-path to reference it without a // space. if(this->WindowsShell && result.find(' ') != result.npos && - cmSystemTools::FileExists(remote)) + cmSystemTools::FileExists(remote.c_str())) { std::string tmp; - if(cmSystemTools::GetShortPath(remote, tmp)) + if(cmSystemTools::GetShortPath(remote.c_str(), tmp)) { return this->Convert(tmp.c_str(), NONE, format, true); } @@ -1250,7 +1253,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToOutputForExisting(const char* remote, +cmLocalGenerator::ConvertToOutputForExisting(const std::string& remote, RelativeRoot local, OutputFormat format) { @@ -1264,7 +1267,7 @@ cmLocalGenerator::ConvertToOutputForExisting(const char* remote, //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote, - const char* local, + const std::string& local, OutputFormat format) { // Perform standard conversion. @@ -1287,10 +1290,11 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path, std::string cmLocalGenerator::GetIncludeFlags( const std::vector<std::string> &includes, cmGeneratorTarget* target, - const char* lang, bool forResponseFile, - const char *config) + const std::string& lang, + bool forResponseFile, + const std::string& config) { - if(!lang) + if(lang.empty()) { return ""; } @@ -1340,7 +1344,7 @@ std::string cmLocalGenerator::GetIncludeFlags( this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); bool flagUsed = false; - std::set<cmStdString> emitted; + std::set<std::string> emitted; #ifdef __APPLE__ emitted.insert("/System/Library/Frameworks"); #endif @@ -1366,7 +1370,7 @@ std::string cmLocalGenerator::GetIncludeFlags( if(!flagUsed || repeatFlag) { if(sysIncludeFlag && target && - target->IsSystemIncludeDirectory(i->c_str(), config)) + target->IsSystemIncludeDirectory(*i, config)) { includeFlags << sysIncludeFlag; } @@ -1401,7 +1405,7 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, cmTarget const* target, - const char* config) + const std::string& config) { std::vector<std::string> targetDefines; target->GetCompileDefinitions(targetDefines, @@ -1412,7 +1416,7 @@ void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileOptions( std::string& flags, cmTarget* target, - const char* lang, const char* config + const std::string& lang, const std::string& config ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; @@ -1460,8 +1464,8 @@ void cmLocalGenerator::AddCompileOptions( //---------------------------------------------------------------------------- void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, cmGeneratorTarget* target, - const char* lang, - const char *config, + const std::string& lang, + const std::string& config, bool stripImplicitInclDirs ) { @@ -1484,7 +1488,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, } // Do not repeat an include path. - std::set<cmStdString> emitted; + std::set<std::string> emitted; // Store the automatic include paths. if(includeBinaryDir) @@ -1686,15 +1690,15 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; } - const char* linkLanguage = target->Target->GetLinkerLanguage(); - if(!linkLanguage) + std::string linkLanguage = target->Target->GetLinkerLanguage(); + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target->Target->GetName()); + target->Target->GetName().c_str()); return; } - this->AddLanguageFlags(flags, linkLanguage, buildType.c_str()); + this->AddLanguageFlags(flags, linkLanguage, buildType); this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *target, false, false); if(cmSystemTools::IsOn @@ -1810,7 +1814,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, // Collect library linking flags command line options. std::string linkLibs; - const char* linkLanguage = cli.GetLinkLanguage(); + std::string linkLanguage = cli.GetLinkLanguage(); std::string libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); @@ -1940,8 +1944,8 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, //---------------------------------------------------------------------------- void cmLocalGenerator::AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target, - const char *lang, - const char* config) + const std::string& lang, + const std::string& config) { // Only add Mac OS X specific flags on Darwin platforms (OSX and iphone): if(!this->Makefile->IsOn("APPLE")) @@ -1966,7 +1970,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG"; const char* deploymentTargetFlag = this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str()); - if(!archs.empty() && lang && (lang[0] =='C' || lang[0] == 'F')) + if(!archs.empty() && !lang.empty() && (lang[0] =='C' || lang[0] == 'F')) { for(std::vector<std::string>::iterator i = archs.begin(); i != archs.end(); ++i) @@ -1997,8 +2001,8 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AddLanguageFlags(std::string& flags, - const char* lang, - const char* config) + const std::string& lang, + const std::string& config) { // Add language-specific flags. std::string flagsVar = "CMAKE_"; @@ -2008,8 +2012,8 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } //---------------------------------------------------------------------------- -bool cmLocalGenerator::GetRealDependency(const char* inName, - const char* config, +bool cmLocalGenerator::GetRealDependency(const std::string& inName, + const std::string& config, std::string& dep) { // Older CMake code may specify the dependency using the target @@ -2036,7 +2040,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, { // make sure it is not just a coincidence that the target name // found is part of the inName - if(cmSystemTools::FileIsFullPath(inName)) + if(cmSystemTools::FileIsFullPath(inName.c_str())) { std::string tLocation; if(target->GetType() >= cmTarget::EXECUTABLE && @@ -2084,7 +2088,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, } // 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. dep = inName; @@ -2109,7 +2113,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, //---------------------------------------------------------------------------- void cmLocalGenerator::AddSharedFlags(std::string& flags, - const char* lang, + const std::string& lang, bool shared) { std::string flagsVar; @@ -2125,7 +2129,8 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, } static void AddVisibilityCompileOption(std::string &flags, cmTarget* target, - cmLocalGenerator *lg, const char *lang) + cmLocalGenerator *lg, + const std::string& lang) { std::string l(lang); std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY"; @@ -2179,7 +2184,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags, //---------------------------------------------------------------------------- void cmLocalGenerator ::AddVisibilityPresetFlags(std::string &flags, cmTarget* target, - const char *lang) + const std::string& lang) { int targetType = target->GetType(); bool suitableTarget = ((targetType == cmTarget::SHARED_LIBRARY) @@ -2191,13 +2196,13 @@ void cmLocalGenerator return; } - if (!lang) + if (lang.empty()) { return; } AddVisibilityCompileOption(flags, target, this, lang); - if(strcmp(lang, "CXX") == 0) + if(lang == "CXX") { AddInlineVisibilityCompileOption(flags, target, this); } @@ -2206,7 +2211,7 @@ void cmLocalGenerator //---------------------------------------------------------------------------- void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target, std::string const& lang, - const char *config) + const std::string& config) { int targetType = target->GetType(); @@ -2321,14 +2326,14 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, - const char* var, - const char* config) + const std::string& var, + const std::string& config) { // Add the flags from the variable itself. std::string flagsVar = var; this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); // Add the flags from the build-type specific variable. - if(config && *config) + if(!config.empty()) { flagsVar += "_"; flagsVar += cmSystemTools::UpperCase(config); @@ -2353,7 +2358,7 @@ void cmLocalGenerator::AppendFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AppendFlagEscape(std::string& flags, - const char* rawFlag) + const std::string& rawFlag) { this->AppendFlags(flags, this->EscapeForShell(rawFlag).c_str()); } @@ -2393,11 +2398,11 @@ void cmLocalGenerator::AppendDefines(std::set<std::string>& defines, //---------------------------------------------------------------------------- void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines, std::string &definesString, - const char* lang) + const std::string& lang) { // Lookup the define flag for the current language. std::string dflag = "-D"; - if(lang) + if(!lang.empty()) { std::string defineFlagVar = "CMAKE_"; defineFlagVar += lang; @@ -2457,7 +2462,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines, //---------------------------------------------------------------------------- void cmLocalGenerator::AppendFeatureOptions( - std::string& flags, const char* lang, const char* feature) + std::string& flags, const std::string& lang, const char* feature) { std::string optVar = "CMAKE_"; optVar += lang; @@ -2508,7 +2513,8 @@ cmLocalGenerator::ConstructComment(const cmCustomCommand& cc, //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToOptionallyRelativeOutputPath(const char* remote) +cmLocalGenerator::ConvertToOptionallyRelativeOutputPath( + const std::string& remote) { return this->Convert(remote, START_OUTPUT, SHELL, true); } @@ -2528,7 +2534,7 @@ const char* cmLocalGenerator::GetRelativeRootPath(RelativeRoot relroot) } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::Convert(const char* source, +std::string cmLocalGenerator::Convert(const std::string& source, RelativeRoot relative, OutputFormat output, bool optional) @@ -2580,7 +2586,7 @@ std::string cmLocalGenerator::Convert(const char* source, } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::ConvertToOutputFormat(const char* source, +std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source, OutputFormat output) { std::string result = source; @@ -2622,7 +2628,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const char* source, //---------------------------------------------------------------------------- std::string cmLocalGenerator::Convert(RelativeRoot remote, - const char* local, + const std::string& local, OutputFormat output, bool optional) { @@ -2631,10 +2637,10 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote, // The relative root must have a path (i.e. not FULL or NONE) assert(remotePath != 0); - if(local && (!optional || this->UseRelativePaths)) + if(!local.empty() && (!optional || this->UseRelativePaths)) { std::vector<std::string> components; - cmSystemTools::SplitPath(local, components); + cmSystemTools::SplitPath(local.c_str(), components); std::string result = this->ConvertToRelativePath(components, remotePath); return this->ConvertToOutputFormat(result.c_str(), output); } @@ -2717,7 +2723,8 @@ static bool cmLocalGeneratorNotAbove(const char* a, const char* b) //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, - const char* in_remote, bool force) + const std::string& in_remote, + bool force) { // The path should never be quoted. assert(in_remote[0] != '\"'); @@ -2726,7 +2733,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, assert(local.size() > 0 && !(local[local.size()-1] == "")); // If the path is already relative then just return the path. - if(!cmSystemTools::FileIsFullPath(in_remote)) + if(!cmSystemTools::FileIsFullPath(in_remote.c_str())) { return in_remote; } @@ -2745,11 +2752,11 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, std::string local_path = cmSystemTools::JoinPath(local); if(!((cmLocalGeneratorNotAbove(local_path.c_str(), this->RelativePathTopBinary.c_str()) && - cmLocalGeneratorNotAbove(in_remote, + cmLocalGeneratorNotAbove(in_remote.c_str(), this->RelativePathTopBinary.c_str())) || (cmLocalGeneratorNotAbove(local_path.c_str(), this->RelativePathTopSource.c_str()) && - cmLocalGeneratorNotAbove(in_remote, + cmLocalGeneratorNotAbove(in_remote.c_str(), this->RelativePathTopSource.c_str())))) { return in_remote; @@ -2759,7 +2766,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, // Identify the longest shared path component between the remote // path and the local path. std::vector<std::string> remote; - cmSystemTools::SplitPath(in_remote, remote); + cmSystemTools::SplitPath(in_remote.c_str(), remote); unsigned int common=0; while(common < remote.size() && common < local.size() && @@ -2830,7 +2837,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, void cmLocalGenerator ::GenerateTargetInstallRules( - std::ostream& os, const char* config, + std::ostream& os, const std::string& config, std::vector<std::string> const& configurationTypes) { // Convert the old-style install specification from each target to @@ -2977,11 +2984,11 @@ bool cmLocalGeneratorCheckObjectName(std::string& objName, //---------------------------------------------------------------------------- std::string& cmLocalGenerator -::CreateSafeUniqueObjectFileName(const char* sin, +::CreateSafeUniqueObjectFileName(const std::string& sin, std::string const& dir_max) { // Look for an existing mapped name for this object file. - std::map<cmStdString,cmStdString>::iterator it = + std::map<std::string,std::string>::iterator it = this->UniqueObjectNamesMap.find(sin); // If no entry exists create one. @@ -3064,7 +3071,7 @@ cmLocalGenerator #endif // Insert the newly mapped object file name. - std::map<cmStdString, cmStdString>::value_type e(sin, ssin); + std::map<std::string, std::string>::value_type e(sin, ssin); it = this->UniqueObjectNamesMap.insert(e).first; } @@ -3137,7 +3144,8 @@ cmLocalGenerator bool replaceExt = this->NeedBackwardsCompatibility_2_4(); if(!replaceExt) { - if(const char* lang = source.GetLanguage()) + std::string lang = source.GetLanguage(); + if(!lang.empty()) { std::string repVar = "CMAKE_"; repVar += lang; @@ -3171,7 +3179,7 @@ cmLocalGenerator } //---------------------------------------------------------------------------- -const char* +std::string cmLocalGenerator ::GetSourceFileLanguage(const cmSourceFile& source) { @@ -3179,7 +3187,7 @@ cmLocalGenerator } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) +std::string cmLocalGenerator::EscapeForShellOldStyle(const std::string& str) { std::string result; #if defined(_WIN32) && !defined(__CYGWIN__) @@ -3195,7 +3203,7 @@ std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) } return str; #else - for(const char* ch = str; *ch != '\0'; ++ch) + for(const char* ch = str.c_str(); *ch != '\0'; ++ch) { if(*ch == ' ') { @@ -3208,28 +3216,30 @@ std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) } //---------------------------------------------------------------------------- -static bool cmLocalGeneratorIsShellOperator(const char* str) -{ - if(strcmp(str, "<") == 0 || - strcmp(str, ">") == 0 || - strcmp(str, "<<") == 0 || - strcmp(str, ">>") == 0 || - strcmp(str, "|") == 0 || - strcmp(str, "||") == 0 || - strcmp(str, "&&") == 0 || - strcmp(str, "&>") == 0 || - strcmp(str, "1>") == 0 || - strcmp(str, "2>") == 0 || - strcmp(str, "2>&1") == 0 || - strcmp(str, "1>&2") == 0) +static bool cmLocalGeneratorIsShellOperator(const std::string& str) +{ + static std::set<std::string> shellOperators; + if(shellOperators.empty()) { - return true; + shellOperators.insert("<"); + shellOperators.insert(">"); + shellOperators.insert("<<"); + shellOperators.insert(">>"); + shellOperators.insert("|"); + shellOperators.insert("||"); + shellOperators.insert("&&"); + shellOperators.insert("&>"); + shellOperators.insert("1>"); + shellOperators.insert("2>"); + shellOperators.insert("2>&1"); + shellOperators.insert("1>&2"); } - return false; + return shellOperators.count(str) > 0; } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, +std::string cmLocalGenerator::EscapeForShell(const std::string& str, + bool makeVars, bool forEcho) { // Do not escape shell operators. @@ -3271,28 +3281,28 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, // Compute the buffer size needed. int size = (this->WindowsShell ? - cmsysSystem_Shell_GetArgumentSizeForWindows(str, flags) : - cmsysSystem_Shell_GetArgumentSizeForUnix(str, flags)); + cmsysSystem_Shell_GetArgumentSizeForWindows(str.c_str(), flags) : + cmsysSystem_Shell_GetArgumentSizeForUnix(str.c_str(), flags)); // Compute the shell argument itself. std::vector<char> arg(size); if(this->WindowsShell) { - cmsysSystem_Shell_GetArgumentForWindows(str, &arg[0], flags); + cmsysSystem_Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags); } else { - cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags); + cmsysSystem_Shell_GetArgumentForUnix(str.c_str(), &arg[0], flags); } return std::string(&arg[0]); } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::EscapeForCMake(const char* str) +std::string cmLocalGenerator::EscapeForCMake(const std::string& str) { // Always double-quote the argument to take care of most escapes. std::string result = "\""; - for(const char* c = str; *c; ++c) + for(const char* c = str.c_str(); *c; ++c) { if(*c == '"') { @@ -3455,17 +3465,18 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const } //---------------------------------------------------------------------------- -static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, const char* prop) +static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, + const std::string& prop) { if(const char* val = target->GetProperty(prop)) { - mf->AddDefinition(prop, val); + mf->AddDefinition(prop.c_str(), val); } } //---------------------------------------------------------------------------- void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, - const char* targetName, + const std::string& targetName, const char* fname) { // Find the Info.plist template. @@ -3494,7 +3505,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, // back to the directory-level values set by the user. cmMakefile* mf = this->Makefile; 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_ICON_FILE"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER"); @@ -3509,8 +3520,8 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, //---------------------------------------------------------------------------- void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, - const char* targetName, - const char* fname) + const std::string& targetName, + const char* fname) { // Find the Info.plist template. const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST"); @@ -3538,7 +3549,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, // back to the directory-level values set by the user. cmMakefile* mf = this->Makefile; 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_IDENTIFIER"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING"); |