diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index f117475e922d47895149994687318e11e3e50c34..e510fcf9f1ea1f32b2ce57062ca4fb09524a718b 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -122,35 +122,6 @@ struct DefaultDeleter<Range, /* valueTypeIsPair = */ true> } }; -template<typename const_iterator_> -struct Range -{ - typedef const_iterator_ const_iterator; - typedef typename std::iterator_traits<const_iterator>::value_type value_type; - typedef typename std::iterator_traits<const_iterator>::difference_type - difference_type; - Range(const_iterator begin_, const_iterator end_) - : Begin(begin_), End(end_) {} - const_iterator begin() const { return Begin; } - const_iterator end() const { return End; } - bool empty() const { return std::distance(Begin, End) == 0; } - difference_type size() const { return std::distance(Begin, End); } - Range& advance(cmIML_INT_intptr_t amount) - { - std::advance(Begin, amount); - return *this; - } - - Range& retreat(cmIML_INT_intptr_t amount) - { - std::advance(End, -amount); - return *this; - } -private: - const_iterator Begin; - const_iterator End; -}; - template<typename FwdIt> FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n) { @@ -178,17 +149,52 @@ private: } +template<typename const_iterator_> +struct cmRange +{ + typedef const_iterator_ const_iterator; + typedef typename std::iterator_traits<const_iterator>::value_type value_type; + typedef typename std::iterator_traits<const_iterator>::difference_type + difference_type; + cmRange(const_iterator begin_, const_iterator end_) + : Begin(begin_), End(end_) {} + const_iterator begin() const { return Begin; } + const_iterator end() const { return End; } + bool empty() const { return std::distance(Begin, End) == 0; } + difference_type size() const { return std::distance(Begin, End); } + cmRange& advance(cmIML_INT_intptr_t amount) + { + std::advance(Begin, amount); + return *this; + } + + cmRange& retreat(cmIML_INT_intptr_t amount) + { + std::advance(End, -amount); + return *this; + } +private: + const_iterator Begin; + const_iterator End; +}; + +typedef cmRange<std::vector<std::string>::const_iterator> cmStringRange; + +class cmListFileBacktrace; +typedef +cmRange<std::vector<cmListFileBacktrace>::const_iterator> cmBacktraceRange; + template<typename Iter1, typename Iter2> -ContainerAlgorithms::Range<Iter1> cmRange(Iter1 begin, Iter2 end) +cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end) { - return ContainerAlgorithms::Range<Iter1>(begin, end); + return cmRange<Iter1>(begin, end); } template<typename Range> -ContainerAlgorithms::Range<typename Range::const_iterator> -cmRange(Range const& range) +cmRange<typename Range::const_iterator> +cmMakeRange(Range const& range) { - return ContainerAlgorithms::Range<typename Range::const_iterator>( + return cmRange<typename Range::const_iterator>( range.begin(), range.end()); } @@ -350,10 +356,10 @@ typename Range::const_iterator cmFindNot(Range const& r, T const& t) } template<typename Range> -ContainerAlgorithms::Range<typename Range::const_reverse_iterator> +cmRange<typename Range::const_reverse_iterator> cmReverseRange(Range const& range) { - return ContainerAlgorithms::Range<typename Range::const_reverse_iterator>( + return cmRange<typename Range::const_reverse_iterator>( range.rbegin(), range.rend()); } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 3d84f3827a1e48a3bfac2436c8bc39591541ee86..0daed66c2ca5c4a29bf5190143a9eb3708223d81 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -270,7 +270,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, this->SetError(error); return false; } - std::string message = cmJoin(cmRange(i, args.end()), std::string()); + std::string message = cmJoin(cmMakeRange(i, args.end()), std::string()); file << message; file.close(); if(mode) diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index add06a7308fce76e72626a71449307a80bacdba3..7959ffe3b526f7fe27bff6e7885fb6a94dd6526f 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -170,8 +170,8 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) else { this->VariableDocumentation += "one of the "; - this->VariableDocumentation += cmJoin(cmRange(this->Names).retreat(1), - ", "); + this->VariableDocumentation += + cmJoin(cmMakeRange(this->Names).retreat(1), ", "); this->VariableDocumentation += " or " + this->Names[this->Names.size() - 1] + " libraries be found"; } diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 78853cebae3439a14b94810ea33e2d0bfeca8f6a..c883ad74371f984a7a99a45f68d8b5356c70aaa8 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -125,7 +125,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass std::string argvDef = cmJoin(expandedArgs, ";"); std::vector<std::string>::const_iterator eit = expandedArgs.begin() + (this->Args.size()-1); - std::string argnDef = cmJoin(cmRange(eit, expandedArgs.end()), ";"); + std::string argnDef = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";"); this->Makefile->AddDefinition("ARGV", argvDef.c_str()); this->Makefile->MarkVariableAsUsed("ARGV"); this->Makefile->AddDefinition("ARGN", argnDef.c_str()); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 88ac0bcd4f64e3a49c8461e8d1db0b3ec0711251..40a85861149deab91551ed3040f44f4de24594ec 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1417,8 +1417,10 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() { cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); - const std::vector<cmValueWithOrigin> noconfig_compile_definitions = + const cmStringRange noconfig_compile_definitions = mf->GetCompileDefinitionsEntries(); + const cmBacktraceRange noconfig_compile_definitions_bts = + mf->GetCompileDefinitionsBacktraces(); cmTargets& targets = mf->GetTargets(); for(cmTargets::iterator ti = targets.begin(); @@ -1433,11 +1435,13 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() continue; } - for (std::vector<cmValueWithOrigin>::const_iterator it + cmBacktraceRange::const_iterator btIt + = noconfig_compile_definitions_bts.begin(); + for (cmStringRange::const_iterator it = noconfig_compile_definitions.begin(); - it != noconfig_compile_definitions.end(); ++it) + it != noconfig_compile_definitions.end(); ++it, ++btIt) { - t->InsertCompileDefinition(*it); + t->InsertCompileDefinition(*it, *btIt); } cmPolicies::PolicyStatus polSt diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index f96b4a824efe1c0f2bf52bbb3cfc2689caabc461..6041fb77db9ee2161dde15c0c69106325fe3ae43 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -247,7 +247,7 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args) { listString += ";"; } - listString += cmJoin(cmRange(args).advance(2), ";"); + listString += cmJoin(cmMakeRange(args).advance(2), ";"); this->Makefile->AddDefinition(listName, listString.c_str()); return true; @@ -361,9 +361,9 @@ bool cmListCommand std::vector<std::string>::const_iterator remBegin = remove.begin(); std::vector<std::string>::const_iterator argsEnd = - cmRemoveMatching(varArgsExpanded, cmRange(remBegin, remEnd)); + cmRemoveMatching(varArgsExpanded, cmMakeRange(remBegin, remEnd)); std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin(); - std::string value = cmJoin(cmRange(argsBegin, argsEnd), ";"); + std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";"); this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -421,7 +421,7 @@ bool cmListCommand cmRemoveDuplicates(varArgsExpanded); std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin(); - std::string value = cmJoin(cmRange(argsBegin, argsEnd), ";"); + std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";"); this->Makefile->AddDefinition(listName, value.c_str()); return true; @@ -509,9 +509,9 @@ bool cmListCommand::HandleRemoveAtCommand( std::vector<size_t>::const_iterator remBegin = removed.begin(); std::vector<std::string>::const_iterator argsEnd = - cmRemoveIndices(varArgsExpanded, cmRange(remBegin, remEnd)); + cmRemoveIndices(varArgsExpanded, cmMakeRange(remBegin, remEnd)); std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin(); - std::string value = cmJoin(cmRange(argsBegin, argsEnd), ";"); + std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";"); this->Makefile->AddDefinition(listName, value.c_str()); return true; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 077d4d93aa89a2c7dbf14f1eaf7f27290c24c5a3..ca4d359cef5a80a487fa1171a7fa68d710f32040 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2259,7 +2259,7 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p, std::string()); std::vector<std::string>::const_iterator compStart = components.begin() + 1; - result += cmJoin(cmRange(compStart, compEnd), slash); + result += cmJoin(cmMakeRange(compStart, compEnd), slash); // Only the last component can be empty to avoid double slashes. result += slash; result += components.back(); diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index fa5a623543d641c04a64027aeb0ac188f6da935c..e4026b084ce713a052058e4119175136993490e4 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -107,7 +107,7 @@ bool cmMacroHelperCommand::InvokeInitialPass std::vector<std::string>::const_iterator eit = expandedArgs.begin() + (this->Args.size() - 1); - std::string expandedArgn = cmJoin(cmRange(eit, expandedArgs.end()), ";"); + std::string expandedArgn = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";"); std::string expandedArgv = cmJoin(expandedArgs, ";"); std::vector<std::string> variables; variables.reserve(this->Args.size() - 1); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ae69b24b6e5203e801ca5a40be9bd5aebcbb6daa..81c88317d679acd088a76ec10f49d1ff31da1fcf 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -273,6 +273,36 @@ void cmMakefile::IssueMessage(cmake::MessageType t, } } +cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const +{ + return cmMakeRange(this->IncludeDirectoriesEntries); +} + +cmBacktraceRange cmMakefile::GetIncludeDirectoriesBacktraces() const +{ + return cmMakeRange(this->IncludeDirectoriesEntryBacktraces); +} + +cmStringRange cmMakefile::GetCompileOptionsEntries() const +{ + return cmMakeRange(this->CompileOptionsEntries); +} + +cmBacktraceRange cmMakefile::GetCompileOptionsBacktraces() const +{ + return cmMakeRange(this->CompileOptionsEntryBacktraces); +} + +cmStringRange cmMakefile::GetCompileDefinitionsEntries() const +{ + return cmMakeRange(this->CompileDefinitionsEntries); +} + +cmBacktraceRange cmMakefile::GetCompileDefinitionsBacktraces() const +{ + return cmMakeRange(this->CompileDefinitionsEntryBacktraces); +} + //---------------------------------------------------------------------------- cmListFileBacktrace cmMakefile::GetBacktrace() const { @@ -1427,7 +1457,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) std::remove(defs.begin(), defs.end(), define); std::vector<std::string>::const_iterator defBegin = defs.begin(); - std::string ndefs = cmJoin(cmRange(defBegin, defEnd), ";"); + std::string ndefs = cmJoin(cmMakeRange(defBegin, defEnd), ";"); // Store the new list. this->SetProperty("COMPILE_DEFINITIONS", ndefs.c_str()); @@ -1527,23 +1557,32 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", this->GetCurrentBinaryDirectory()); - const std::vector<cmValueWithOrigin>& parentIncludes = - parent->GetIncludeDirectoriesEntries(); - this->IncludeDirectoriesEntries.insert(this->IncludeDirectoriesEntries.end(), - parentIncludes.begin(), - parentIncludes.end()); - - const std::vector<cmValueWithOrigin>& parentOptions = - parent->GetCompileOptionsEntries(); - this->CompileOptionsEntries.insert(this->CompileOptionsEntries.end(), - parentOptions.begin(), - parentOptions.end()); - - const std::vector<cmValueWithOrigin>& parentDefines = - parent->GetCompileDefinitionsEntries(); - this->CompileDefinitionsEntries.insert(this->CompileDefinitionsEntries.end(), - parentDefines.begin(), - parentDefines.end()); + this->IncludeDirectoriesEntries.insert( + this->IncludeDirectoriesEntries.end(), + parent->IncludeDirectoriesEntries.begin(), + parent->IncludeDirectoriesEntries.end()); + this->IncludeDirectoriesEntryBacktraces.insert( + this->IncludeDirectoriesEntryBacktraces.end(), + parent->IncludeDirectoriesEntryBacktraces.begin(), + parent->IncludeDirectoriesEntryBacktraces.end()); + + this->CompileOptionsEntries.insert( + this->CompileOptionsEntries.end(), + parent->CompileOptionsEntries.begin(), + parent->CompileOptionsEntries.end()); + this->CompileOptionsEntryBacktraces.insert( + this->CompileOptionsEntryBacktraces.end(), + parent->CompileOptionsEntryBacktraces.begin(), + parent->CompileOptionsEntryBacktraces.end()); + + this->CompileDefinitionsEntries.insert( + this->CompileDefinitionsEntries.end(), + parent->CompileDefinitionsEntries.begin(), + parent->CompileDefinitionsEntries.end()); + this->CompileDefinitionsEntryBacktraces.insert( + this->CompileDefinitionsEntryBacktraces.end(), + parent->CompileDefinitionsEntryBacktraces.begin(), + parent->CompileDefinitionsEntryBacktraces.end()); this->SystemIncludeDirectories = parent->SystemIncludeDirectories; @@ -1887,20 +1926,24 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs, return; } - std::vector<cmValueWithOrigin>::iterator position = + std::vector<std::string>::iterator position = before ? this->IncludeDirectoriesEntries.begin() : this->IncludeDirectoriesEntries.end(); + std::vector<cmListFileBacktrace>::iterator btPos = + this->IncludeDirectoriesEntryBacktraces.begin() + + std::distance(this->IncludeDirectoriesEntries.begin(), position); cmListFileBacktrace lfbt = this->GetBacktrace(); - cmValueWithOrigin entry(cmJoin(incs, ";"), lfbt); - this->IncludeDirectoriesEntries.insert(position, entry); + std::string entryString = cmJoin(incs, ";"); + this->IncludeDirectoriesEntries.insert(position, entryString); + this->IncludeDirectoriesEntryBacktraces.insert(btPos, lfbt); // Property on each target: for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end(); ++l) { cmTarget &t = l->second; - t.InsertInclude(entry, before); + t.InsertInclude(entryString, lfbt, before); } } @@ -4120,36 +4163,40 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value) if (prop == "INCLUDE_DIRECTORIES") { this->IncludeDirectoriesEntries.clear(); + this->IncludeDirectoriesEntryBacktraces.clear(); if (!value) { return; } cmListFileBacktrace lfbt = this->GetBacktrace(); - this->IncludeDirectoriesEntries.push_back( - cmValueWithOrigin(value, lfbt)); + this->IncludeDirectoriesEntries.push_back(value); + this->IncludeDirectoriesEntryBacktraces.push_back(lfbt); return; } if (prop == "COMPILE_OPTIONS") { this->CompileOptionsEntries.clear(); + this->CompileDefinitionsEntryBacktraces.clear(); if (!value) { return; } cmListFileBacktrace lfbt = this->GetBacktrace(); - this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt)); + this->CompileOptionsEntries.push_back(value); + this->CompileOptionsEntryBacktraces.push_back(lfbt); return; } if (prop == "COMPILE_DEFINITIONS") { this->CompileDefinitionsEntries.clear(); + this->CompileDefinitionsEntryBacktraces.clear(); if (!value) { return; } cmListFileBacktrace lfbt = this->GetBacktrace(); - cmValueWithOrigin entry(value, lfbt); - this->CompileDefinitionsEntries.push_back(entry); + this->CompileDefinitionsEntries.push_back(value); + this->CompileDefinitionsEntryBacktraces.push_back(lfbt); return; } @@ -4163,22 +4210,22 @@ void cmMakefile::AppendProperty(const std::string& prop, if (prop == "INCLUDE_DIRECTORIES") { cmListFileBacktrace lfbt = this->GetBacktrace(); - this->IncludeDirectoriesEntries.push_back( - cmValueWithOrigin(value, lfbt)); + this->IncludeDirectoriesEntries.push_back(value); + this->IncludeDirectoriesEntryBacktraces.push_back(lfbt); return; } if (prop == "COMPILE_OPTIONS") { cmListFileBacktrace lfbt = this->GetBacktrace(); - this->CompileOptionsEntries.push_back( - cmValueWithOrigin(value, lfbt)); + this->CompileOptionsEntries.push_back(value); + this->CompileOptionsEntryBacktraces.push_back(lfbt); return; } if (prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt = this->GetBacktrace(); - this->CompileDefinitionsEntries.push_back( - cmValueWithOrigin(value, lfbt)); + this->CompileDefinitionsEntries.push_back(value); + this->CompileDefinitionsEntryBacktraces.push_back(lfbt); return; } @@ -4233,44 +4280,17 @@ const char *cmMakefile::GetProperty(const std::string& prop, } else if (prop == "INCLUDE_DIRECTORIES") { - std::string sep; - for (std::vector<cmValueWithOrigin>::const_iterator - it = this->IncludeDirectoriesEntries.begin(), - end = this->IncludeDirectoriesEntries.end(); - it != end; ++it) - { - output += sep; - output += it->Value; - sep = ";"; - } + output = cmJoin(this->IncludeDirectoriesEntries, ";"); return output.c_str(); } else if (prop == "COMPILE_OPTIONS") { - std::string sep; - for (std::vector<cmValueWithOrigin>::const_iterator - it = this->CompileOptionsEntries.begin(), - end = this->CompileOptionsEntries.end(); - it != end; ++it) - { - output += sep; - output += it->Value; - sep = ";"; - } + output = cmJoin(this->CompileOptionsEntries, ";"); return output.c_str(); } else if (prop == "COMPILE_DEFINITIONS") { - std::string sep; - for (std::vector<cmValueWithOrigin>::const_iterator - it = this->CompileDefinitionsEntries.begin(), - end = this->CompileDefinitionsEntries.end(); - it != end; ++it) - { - output += sep; - output += it->Value; - sep = ";"; - } + output = cmJoin(this->CompileDefinitionsEntries, ";"); return output.c_str(); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 2fc4d78a8a516b9e4344e3d092692d9217626925..27911a97c7fd299201c787d3d832b73e95d48c90 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -22,6 +22,7 @@ #include "cmExpandedCommandArgument.h" #include "cmake.h" #include "cmState.h" +#include "cmAlgorithms.h" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmSourceGroup.h" @@ -746,18 +747,12 @@ public: /** Set whether or not to report a CMP0000 violation. */ void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; } - const std::vector<cmValueWithOrigin>& GetIncludeDirectoriesEntries() const - { - return this->IncludeDirectoriesEntries; - } - const std::vector<cmValueWithOrigin>& GetCompileOptionsEntries() const - { - return this->CompileOptionsEntries; - } - const std::vector<cmValueWithOrigin>& GetCompileDefinitionsEntries() const - { - return this->CompileDefinitionsEntries; - } + cmStringRange GetIncludeDirectoriesEntries() const; + cmBacktraceRange GetIncludeDirectoriesBacktraces() const; + cmStringRange GetCompileOptionsEntries() const; + cmBacktraceRange GetCompileOptionsBacktraces() const; + cmStringRange GetCompileDefinitionsEntries() const; + cmBacktraceRange GetCompileDefinitionsBacktraces() const; bool IsConfigured() const { return this->Configured; } void SetConfigured(){ this->Configured = true; } @@ -851,9 +846,12 @@ protected: std::vector<std::string> HeaderFileExtensions; std::string DefineFlags; - std::vector<cmValueWithOrigin> IncludeDirectoriesEntries; - std::vector<cmValueWithOrigin> CompileOptionsEntries; - std::vector<cmValueWithOrigin> CompileDefinitionsEntries; + std::vector<std::string> IncludeDirectoriesEntries; + std::vector<cmListFileBacktrace> IncludeDirectoriesEntryBacktraces; + std::vector<std::string> CompileOptionsEntries; + std::vector<cmListFileBacktrace> CompileOptionsEntryBacktraces; + std::vector<std::string> CompileDefinitionsEntries; + std::vector<cmListFileBacktrace> CompileDefinitionsEntryBacktraces; // Track the value of the computed DEFINITIONS property. void AddDefineFlag(const char*, std::string&); diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index 0449c501d1a9d1c3da54d200d2c43e983c7a45d9..2854a82bd3c95fbd13d8290f39037f20d2322422 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -69,7 +69,7 @@ bool cmMessageCommand ++i; } - std::string message = cmJoin(cmRange(i, args.end()), std::string()); + std::string message = cmJoin(cmMakeRange(i, args.end()), std::string()); if (type != cmake::MESSAGE) { diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 91f3c0ad54433246f00c809f13fea9628d2f7d8e..7be5b3f47fcb3b0f4fea868645eddb8c8c1e4d14 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -293,7 +293,7 @@ cmOutputConverter::ConvertToRelativePath(const std::vector<std::string>& local, { relative += "/"; } - relative += cmJoin(cmRange(remote).advance(common), "/"); + relative += cmJoin(cmMakeRange(remote).advance(common), "/"); // Finally return the path. return relative; diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index bf9f42c8a5b9e2c8c21b5a6cf8843bc3d7982285..306276bbae334ee013edb303f9a3682bdea3b99b 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -108,7 +108,7 @@ bool cmSetCommand } // collect any values into a single semi-colon separated value list - value = cmJoin(cmRange(args).advance(1).retreat(ignoreLastArgs), ";"); + value = cmJoin(cmMakeRange(args).advance(1).retreat(ignoreLastArgs), ";"); if (parentScope) { diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index efc1f16273ac3bae9c4b01581471a64c6330489a..649fb39333ea0e77ca362a1b7333ae6bf8cd462c 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -319,7 +319,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) } // Concatenate all the last arguments together. - std::string input = cmJoin(cmRange(args).advance(4), std::string()); + std::string input = cmJoin(cmMakeRange(args).advance(4), std::string()); // Scan through the input for all matches. std::string output; @@ -365,7 +365,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) } // Concatenate all the last arguments together. - std::string input = cmJoin(cmRange(args).advance(4), std::string()); + std::string input = cmJoin(cmMakeRange(args).advance(4), std::string()); // Scan through the input for all matches. std::string output; @@ -465,7 +465,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) } // Concatenate all the last arguments together. - std::string input = cmJoin(cmRange(args).advance(5), std::string()); + std::string input = cmJoin(cmMakeRange(args).advance(5), std::string()); // Scan through the input for all matches. std::string output; @@ -665,7 +665,7 @@ bool cmStringCommand::HandleReplaceCommand(std::vector<std::string> const& const std::string& replaceExpression = args[2]; const std::string& variableName = args[3]; - std::string input = cmJoin(cmRange(args).advance(4), std::string()); + std::string input = cmJoin(cmMakeRange(args).advance(4), std::string()); cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(), replaceExpression.c_str()); @@ -756,7 +756,7 @@ bool cmStringCommand::HandleAppendCommand(std::vector<std::string> const& args) { value = oldValue; } - value += cmJoin(cmRange(args).advance(2), std::string()); + value += cmJoin(cmMakeRange(args).advance(2), std::string()); this->Makefile->AddDefinition(variable, value.c_str()); return true; } @@ -772,7 +772,7 @@ bool cmStringCommand } std::string const& variableName = args[1]; - std::string value = cmJoin(cmRange(args).advance(2), std::string()); + std::string value = cmJoin(cmMakeRange(args).advance(2), std::string()); this->Makefile->AddDefinition(variableName, value.c_str()); return true; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3d8adae9ed1a79523915e0b00b5883217e8a6bde..8520e29cb7f1d616c68a5f995900bc7cc8f560e1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -402,13 +402,17 @@ void cmTarget::SetMakefile(cmMakefile* mf) { // Initialize the INCLUDE_DIRECTORIES property based on the current value // of the same directory property: - const std::vector<cmValueWithOrigin> parentIncludes = - this->Makefile->GetIncludeDirectoriesEntries(); + const cmStringRange parentIncludes = + this->Makefile->GetIncludeDirectoriesEntries(); + const cmBacktraceRange parentIncludesBts = + this->Makefile->GetIncludeDirectoriesBacktraces(); - for (std::vector<cmValueWithOrigin>::const_iterator it - = parentIncludes.begin(); it != parentIncludes.end(); ++it) + cmBacktraceRange::const_iterator btIt = parentIncludesBts.begin(); + for (cmStringRange::const_iterator it + = parentIncludes.begin(); + it != parentIncludes.end(); ++it, ++btIt) { - this->InsertInclude(*it); + this->InsertInclude(*it, *btIt); } const std::set<std::string> parentSystemIncludes = this->Makefile->GetSystemIncludeDirectories(); @@ -416,13 +420,17 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(), parentSystemIncludes.end()); - const std::vector<cmValueWithOrigin> parentOptions = + const cmStringRange parentOptions = this->Makefile->GetCompileOptionsEntries(); + const cmBacktraceRange parentOptionsBts = + this->Makefile->GetCompileOptionsBacktraces(); - for (std::vector<cmValueWithOrigin>::const_iterator it - = parentOptions.begin(); it != parentOptions.end(); ++it) + btIt = parentOptionsBts.begin(); + for (cmStringRange::const_iterator it + = parentOptions.begin(); + it != parentOptions.end(); ++it, ++btIt) { - this->InsertCompileOption(*it); + this->InsertCompileOption(*it, *btIt); } } @@ -1926,40 +1934,43 @@ void cmTarget::AppendBuildInterfaceIncludes() } //---------------------------------------------------------------------------- -void cmTarget::InsertInclude(const cmValueWithOrigin &entry, - bool before) +void cmTarget::InsertInclude(std::string const& entry, + cmListFileBacktrace const& bt, + bool before) { - cmGeneratorExpression ge(entry.Backtrace); + cmGeneratorExpression ge(bt); std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position = before ? this->Internal->IncludeDirectoriesEntries.begin() : this->Internal->IncludeDirectoriesEntries.end(); this->Internal->IncludeDirectoriesEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value))); + new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); } //---------------------------------------------------------------------------- -void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry, - bool before) +void cmTarget::InsertCompileOption(std::string const& entry, + cmListFileBacktrace const& bt, + bool before) { - cmGeneratorExpression ge(entry.Backtrace); + cmGeneratorExpression ge(bt); std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position = before ? this->Internal->CompileOptionsEntries.begin() : this->Internal->CompileOptionsEntries.end(); this->Internal->CompileOptionsEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value))); + new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); } //---------------------------------------------------------------------------- -void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry) +void cmTarget::InsertCompileDefinition(std::string const& entry, + cmListFileBacktrace const& bt) { - cmGeneratorExpression ge(entry.Backtrace); + cmGeneratorExpression ge(bt); this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value))); + new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); } //---------------------------------------------------------------------------- @@ -6686,7 +6697,7 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } std::sort(props.begin(), props.end()); - std::string propsString = cmJoin(cmRange(props).retreat(1), ", "); + std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); propsString += " and the " + props.back(); std::ostringstream e; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1920312552a65dd2779e807b1c853bdf04fd32e4..f9bcb057668f6fa460768d67437bd927e3dc179c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -572,11 +572,14 @@ public: std::vector<std::string> GetIncludeDirectories( const std::string& config, const std::string& language) const; - void InsertInclude(const cmValueWithOrigin &entry, + void InsertInclude(std::string const& entry, + cmListFileBacktrace const& bt, bool before = false); - void InsertCompileOption(const cmValueWithOrigin &entry, - bool before = false); - void InsertCompileDefinition(const cmValueWithOrigin &entry); + void InsertCompileOption(std::string const& entry, + cmListFileBacktrace const& bt, + bool before = false); + void InsertCompileDefinition(std::string const& entry, + cmListFileBacktrace const& bt); void AppendBuildInterfaceIncludes(); diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx index a85153dd50f99a42734548b9fab4bde7dbf4bf53..8e86f0f7950a32e291c7cd9a35ee8bae57da12b5 100644 --- a/Source/cmTargetCompileOptionsCommand.cxx +++ b/Source/cmTargetCompileOptionsCommand.cxx @@ -50,7 +50,6 @@ bool cmTargetCompileOptionsCommand bool, bool) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmValueWithOrigin entry(this->Join(content), lfbt); - tgt->InsertCompileOption(entry); + tgt->InsertCompileOption(this->Join(content), lfbt); return true; } diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 24500db13aef2767478c68aa42f3e8c7f5fabc61..7824c898d96e0789d7b2a395bc78dfcf663f22c4 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -72,8 +72,7 @@ bool cmTargetIncludeDirectoriesCommand bool prepend, bool system) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmValueWithOrigin entry(this->Join(content), lfbt); - tgt->InsertInclude(entry, prepend); + tgt->InsertInclude(this->Join(content), lfbt, prepend); if (system) { tgt->AddSystemIncludeDirectories(content); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 63838b49be45764e47be7cab8045a5cf9fead4d8..71f47f33fc61e4c5ce4bc5b9df26fb01e7a74470 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -335,14 +335,14 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Echo string else if (args[1] == "echo" ) { - std::cout << cmJoin(cmRange(args).advance(2), " ") << std::endl; + std::cout << cmJoin(cmMakeRange(args).advance(2), " ") << std::endl; return 0; } // Echo string no new line else if (args[1] == "echo_append" ) { - std::cout << cmJoin(cmRange(args).advance(2), " "); + std::cout << cmJoin(cmMakeRange(args).advance(2), " "); return 0; } @@ -511,7 +511,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Clock command else if (args[1] == "time" && args.size() > 2) { - std::string command = cmJoin(cmRange(args).advance(2), " "); + std::string command = cmJoin(cmMakeRange(args).advance(2), " "); clock_t clock_start, clock_finish; time_t time_start, time_finish; @@ -572,7 +572,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return 1; } - std::string command = cmWrap('"', cmRange(args).advance(3), '"', " "); + std::string command = + cmWrap('"', cmMakeRange(args).advance(3), '"', " "); int retval = 0; int timeout = 0; if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &retval,