Merge topic 'cmRange-API'

8d336875 cmMakefile: Use Ranges for buildsystem property access.
514a1dff cmAlgorithms: Add some convenient typedefs.
c7b39d06 cmMakefile: Split accessors for include directories and origins.
b2de25ad cmMakefile: Split accessors for compile options and origins.
d6239507 cmMakefile: Split accessors for compile definitions and origins.
ef17bbef cmMakefile: Separate storage of buildsystem properties and their origins.
a89c02ce cmMakefile: Out of line some API.
b19587e7 cmMakefile: Remove some references from APIs.
1fe71e2e cmAlgorithms: Move Range type out of private namespace.
8ea0b81d cmAlgorithms: Rename cmRange to cmMakeRange.
This commit is contained in:
Brad King 2015-07-27 09:31:14 -04:00 committed by CMake Topic Stage
commit 91a159245f
19 changed files with 212 additions and 171 deletions

View File

@ -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> template<typename FwdIt>
FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n) FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n)
{ {
@ -178,17 +149,52 @@ private:
} }
template<typename Iter1, typename Iter2> template<typename const_iterator_>
ContainerAlgorithms::Range<Iter1> cmRange(Iter1 begin, Iter2 end) struct cmRange
{ {
return ContainerAlgorithms::Range<Iter1>(begin, end); 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>
cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end)
{
return cmRange<Iter1>(begin, end);
} }
template<typename Range> template<typename Range>
ContainerAlgorithms::Range<typename Range::const_iterator> cmRange<typename Range::const_iterator>
cmRange(Range const& range) cmMakeRange(Range const& range)
{ {
return ContainerAlgorithms::Range<typename Range::const_iterator>( return cmRange<typename Range::const_iterator>(
range.begin(), range.end()); range.begin(), range.end());
} }
@ -350,10 +356,10 @@ typename Range::const_iterator cmFindNot(Range const& r, T const& t)
} }
template<typename Range> template<typename Range>
ContainerAlgorithms::Range<typename Range::const_reverse_iterator> cmRange<typename Range::const_reverse_iterator>
cmReverseRange(Range const& range) cmReverseRange(Range const& range)
{ {
return ContainerAlgorithms::Range<typename Range::const_reverse_iterator>( return cmRange<typename Range::const_reverse_iterator>(
range.rbegin(), range.rend()); range.rbegin(), range.rend());
} }

View File

@ -270,7 +270,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
this->SetError(error); this->SetError(error);
return false; 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 << message;
file.close(); file.close();
if(mode) if(mode)

View File

@ -170,8 +170,8 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
else else
{ {
this->VariableDocumentation += "one of the "; 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->VariableDocumentation += " or "
+ this->Names[this->Names.size() - 1] + " libraries be found"; + this->Names[this->Names.size() - 1] + " libraries be found";
} }

View File

@ -125,7 +125,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass
std::string argvDef = cmJoin(expandedArgs, ";"); std::string argvDef = cmJoin(expandedArgs, ";");
std::vector<std::string>::const_iterator eit std::vector<std::string>::const_iterator eit
= expandedArgs.begin() + (this->Args.size()-1); = 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->AddDefinition("ARGV", argvDef.c_str());
this->Makefile->MarkVariableAsUsed("ARGV"); this->Makefile->MarkVariableAsUsed("ARGV");
this->Makefile->AddDefinition("ARGN", argnDef.c_str()); this->Makefile->AddDefinition("ARGN", argnDef.c_str());

View File

@ -1417,8 +1417,10 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
{ {
cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
const std::vector<cmValueWithOrigin> noconfig_compile_definitions = const cmStringRange noconfig_compile_definitions =
mf->GetCompileDefinitionsEntries(); mf->GetCompileDefinitionsEntries();
const cmBacktraceRange noconfig_compile_definitions_bts =
mf->GetCompileDefinitionsBacktraces();
cmTargets& targets = mf->GetTargets(); cmTargets& targets = mf->GetTargets();
for(cmTargets::iterator ti = targets.begin(); for(cmTargets::iterator ti = targets.begin();
@ -1433,11 +1435,13 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
continue; 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(); = 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 cmPolicies::PolicyStatus polSt

View File

@ -247,7 +247,7 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
{ {
listString += ";"; listString += ";";
} }
listString += cmJoin(cmRange(args).advance(2), ";"); listString += cmJoin(cmMakeRange(args).advance(2), ";");
this->Makefile->AddDefinition(listName, listString.c_str()); this->Makefile->AddDefinition(listName, listString.c_str());
return true; return true;
@ -361,9 +361,9 @@ bool cmListCommand
std::vector<std::string>::const_iterator remBegin = remove.begin(); std::vector<std::string>::const_iterator remBegin = remove.begin();
std::vector<std::string>::const_iterator argsEnd = 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::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()); this->Makefile->AddDefinition(listName, value.c_str());
return true; return true;
} }
@ -421,7 +421,7 @@ bool cmListCommand
cmRemoveDuplicates(varArgsExpanded); cmRemoveDuplicates(varArgsExpanded);
std::vector<std::string>::const_iterator argsBegin = std::vector<std::string>::const_iterator argsBegin =
varArgsExpanded.begin(); varArgsExpanded.begin();
std::string value = cmJoin(cmRange(argsBegin, argsEnd), ";"); std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";");
this->Makefile->AddDefinition(listName, value.c_str()); this->Makefile->AddDefinition(listName, value.c_str());
return true; return true;
@ -509,9 +509,9 @@ bool cmListCommand::HandleRemoveAtCommand(
std::vector<size_t>::const_iterator remBegin = removed.begin(); std::vector<size_t>::const_iterator remBegin = removed.begin();
std::vector<std::string>::const_iterator argsEnd = 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::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()); this->Makefile->AddDefinition(listName, value.c_str());
return true; return true;

View File

@ -2259,7 +2259,7 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
std::string()); std::string());
std::vector<std::string>::const_iterator compStart std::vector<std::string>::const_iterator compStart
= components.begin() + 1; = 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. // Only the last component can be empty to avoid double slashes.
result += slash; result += slash;
result += components.back(); result += components.back();

View File

@ -107,7 +107,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
std::vector<std::string>::const_iterator eit std::vector<std::string>::const_iterator eit
= expandedArgs.begin() + (this->Args.size() - 1); = 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::string expandedArgv = cmJoin(expandedArgs, ";");
std::vector<std::string> variables; std::vector<std::string> variables;
variables.reserve(this->Args.size() - 1); variables.reserve(this->Args.size() - 1);

View File

@ -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 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::remove(defs.begin(), defs.end(), define);
std::vector<std::string>::const_iterator defBegin = std::vector<std::string>::const_iterator defBegin =
defs.begin(); defs.begin();
std::string ndefs = cmJoin(cmRange(defBegin, defEnd), ";"); std::string ndefs = cmJoin(cmMakeRange(defBegin, defEnd), ";");
// Store the new list. // Store the new list.
this->SetProperty("COMPILE_DEFINITIONS", ndefs.c_str()); this->SetProperty("COMPILE_DEFINITIONS", ndefs.c_str());
@ -1527,23 +1557,32 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
this->GetCurrentBinaryDirectory()); this->GetCurrentBinaryDirectory());
const std::vector<cmValueWithOrigin>& parentIncludes = this->IncludeDirectoriesEntries.insert(
parent->GetIncludeDirectoriesEntries(); this->IncludeDirectoriesEntries.end(),
this->IncludeDirectoriesEntries.insert(this->IncludeDirectoriesEntries.end(), parent->IncludeDirectoriesEntries.begin(),
parentIncludes.begin(), parent->IncludeDirectoriesEntries.end());
parentIncludes.end()); this->IncludeDirectoriesEntryBacktraces.insert(
this->IncludeDirectoriesEntryBacktraces.end(),
parent->IncludeDirectoriesEntryBacktraces.begin(),
parent->IncludeDirectoriesEntryBacktraces.end());
const std::vector<cmValueWithOrigin>& parentOptions = this->CompileOptionsEntries.insert(
parent->GetCompileOptionsEntries(); this->CompileOptionsEntries.end(),
this->CompileOptionsEntries.insert(this->CompileOptionsEntries.end(), parent->CompileOptionsEntries.begin(),
parentOptions.begin(), parent->CompileOptionsEntries.end());
parentOptions.end()); this->CompileOptionsEntryBacktraces.insert(
this->CompileOptionsEntryBacktraces.end(),
parent->CompileOptionsEntryBacktraces.begin(),
parent->CompileOptionsEntryBacktraces.end());
const std::vector<cmValueWithOrigin>& parentDefines = this->CompileDefinitionsEntries.insert(
parent->GetCompileDefinitionsEntries(); this->CompileDefinitionsEntries.end(),
this->CompileDefinitionsEntries.insert(this->CompileDefinitionsEntries.end(), parent->CompileDefinitionsEntries.begin(),
parentDefines.begin(), parent->CompileDefinitionsEntries.end());
parentDefines.end()); this->CompileDefinitionsEntryBacktraces.insert(
this->CompileDefinitionsEntryBacktraces.end(),
parent->CompileDefinitionsEntryBacktraces.begin(),
parent->CompileDefinitionsEntryBacktraces.end());
this->SystemIncludeDirectories = parent->SystemIncludeDirectories; this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
@ -1887,20 +1926,24 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
return; return;
} }
std::vector<cmValueWithOrigin>::iterator position = std::vector<std::string>::iterator position =
before ? this->IncludeDirectoriesEntries.begin() before ? this->IncludeDirectoriesEntries.begin()
: this->IncludeDirectoriesEntries.end(); : this->IncludeDirectoriesEntries.end();
std::vector<cmListFileBacktrace>::iterator btPos =
this->IncludeDirectoriesEntryBacktraces.begin()
+ std::distance(this->IncludeDirectoriesEntries.begin(), position);
cmListFileBacktrace lfbt = this->GetBacktrace(); cmListFileBacktrace lfbt = this->GetBacktrace();
cmValueWithOrigin entry(cmJoin(incs, ";"), lfbt); std::string entryString = cmJoin(incs, ";");
this->IncludeDirectoriesEntries.insert(position, entry); this->IncludeDirectoriesEntries.insert(position, entryString);
this->IncludeDirectoriesEntryBacktraces.insert(btPos, lfbt);
// Property on each target: // Property on each target:
for (cmTargets::iterator l = this->Targets.begin(); for (cmTargets::iterator l = this->Targets.begin();
l != this->Targets.end(); ++l) l != this->Targets.end(); ++l)
{ {
cmTarget &t = l->second; 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") if (prop == "INCLUDE_DIRECTORIES")
{ {
this->IncludeDirectoriesEntries.clear(); this->IncludeDirectoriesEntries.clear();
this->IncludeDirectoriesEntryBacktraces.clear();
if (!value) if (!value)
{ {
return; return;
} }
cmListFileBacktrace lfbt = this->GetBacktrace(); cmListFileBacktrace lfbt = this->GetBacktrace();
this->IncludeDirectoriesEntries.push_back( this->IncludeDirectoriesEntries.push_back(value);
cmValueWithOrigin(value, lfbt)); this->IncludeDirectoriesEntryBacktraces.push_back(lfbt);
return; return;
} }
if (prop == "COMPILE_OPTIONS") if (prop == "COMPILE_OPTIONS")
{ {
this->CompileOptionsEntries.clear(); this->CompileOptionsEntries.clear();
this->CompileDefinitionsEntryBacktraces.clear();
if (!value) if (!value)
{ {
return; return;
} }
cmListFileBacktrace lfbt = this->GetBacktrace(); cmListFileBacktrace lfbt = this->GetBacktrace();
this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt)); this->CompileOptionsEntries.push_back(value);
this->CompileOptionsEntryBacktraces.push_back(lfbt);
return; return;
} }
if (prop == "COMPILE_DEFINITIONS") if (prop == "COMPILE_DEFINITIONS")
{ {
this->CompileDefinitionsEntries.clear(); this->CompileDefinitionsEntries.clear();
this->CompileDefinitionsEntryBacktraces.clear();
if (!value) if (!value)
{ {
return; return;
} }
cmListFileBacktrace lfbt = this->GetBacktrace(); cmListFileBacktrace lfbt = this->GetBacktrace();
cmValueWithOrigin entry(value, lfbt); this->CompileDefinitionsEntries.push_back(value);
this->CompileDefinitionsEntries.push_back(entry); this->CompileDefinitionsEntryBacktraces.push_back(lfbt);
return; return;
} }
@ -4163,22 +4210,22 @@ void cmMakefile::AppendProperty(const std::string& prop,
if (prop == "INCLUDE_DIRECTORIES") if (prop == "INCLUDE_DIRECTORIES")
{ {
cmListFileBacktrace lfbt = this->GetBacktrace(); cmListFileBacktrace lfbt = this->GetBacktrace();
this->IncludeDirectoriesEntries.push_back( this->IncludeDirectoriesEntries.push_back(value);
cmValueWithOrigin(value, lfbt)); this->IncludeDirectoriesEntryBacktraces.push_back(lfbt);
return; return;
} }
if (prop == "COMPILE_OPTIONS") if (prop == "COMPILE_OPTIONS")
{ {
cmListFileBacktrace lfbt = this->GetBacktrace(); cmListFileBacktrace lfbt = this->GetBacktrace();
this->CompileOptionsEntries.push_back( this->CompileOptionsEntries.push_back(value);
cmValueWithOrigin(value, lfbt)); this->CompileOptionsEntryBacktraces.push_back(lfbt);
return; return;
} }
if (prop == "COMPILE_DEFINITIONS") if (prop == "COMPILE_DEFINITIONS")
{ {
cmListFileBacktrace lfbt = this->GetBacktrace(); cmListFileBacktrace lfbt = this->GetBacktrace();
this->CompileDefinitionsEntries.push_back( this->CompileDefinitionsEntries.push_back(value);
cmValueWithOrigin(value, lfbt)); this->CompileDefinitionsEntryBacktraces.push_back(lfbt);
return; return;
} }
@ -4233,44 +4280,17 @@ const char *cmMakefile::GetProperty(const std::string& prop,
} }
else if (prop == "INCLUDE_DIRECTORIES") else if (prop == "INCLUDE_DIRECTORIES")
{ {
std::string sep; output = cmJoin(this->IncludeDirectoriesEntries, ";");
for (std::vector<cmValueWithOrigin>::const_iterator
it = this->IncludeDirectoriesEntries.begin(),
end = this->IncludeDirectoriesEntries.end();
it != end; ++it)
{
output += sep;
output += it->Value;
sep = ";";
}
return output.c_str(); return output.c_str();
} }
else if (prop == "COMPILE_OPTIONS") else if (prop == "COMPILE_OPTIONS")
{ {
std::string sep; output = cmJoin(this->CompileOptionsEntries, ";");
for (std::vector<cmValueWithOrigin>::const_iterator
it = this->CompileOptionsEntries.begin(),
end = this->CompileOptionsEntries.end();
it != end; ++it)
{
output += sep;
output += it->Value;
sep = ";";
}
return output.c_str(); return output.c_str();
} }
else if (prop == "COMPILE_DEFINITIONS") else if (prop == "COMPILE_DEFINITIONS")
{ {
std::string sep; output = cmJoin(this->CompileDefinitionsEntries, ";");
for (std::vector<cmValueWithOrigin>::const_iterator
it = this->CompileDefinitionsEntries.begin(),
end = this->CompileDefinitionsEntries.end();
it != end; ++it)
{
output += sep;
output += it->Value;
sep = ";";
}
return output.c_str(); return output.c_str();
} }

View File

@ -22,6 +22,7 @@
#include "cmExpandedCommandArgument.h" #include "cmExpandedCommandArgument.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h" #include "cmState.h"
#include "cmAlgorithms.h"
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
#include "cmSourceGroup.h" #include "cmSourceGroup.h"
@ -746,18 +747,12 @@ public:
/** Set whether or not to report a CMP0000 violation. */ /** Set whether or not to report a CMP0000 violation. */
void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; } void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; }
const std::vector<cmValueWithOrigin>& GetIncludeDirectoriesEntries() const cmStringRange GetIncludeDirectoriesEntries() const;
{ cmBacktraceRange GetIncludeDirectoriesBacktraces() const;
return this->IncludeDirectoriesEntries; cmStringRange GetCompileOptionsEntries() const;
} cmBacktraceRange GetCompileOptionsBacktraces() const;
const std::vector<cmValueWithOrigin>& GetCompileOptionsEntries() const cmStringRange GetCompileDefinitionsEntries() const;
{ cmBacktraceRange GetCompileDefinitionsBacktraces() const;
return this->CompileOptionsEntries;
}
const std::vector<cmValueWithOrigin>& GetCompileDefinitionsEntries() const
{
return this->CompileDefinitionsEntries;
}
bool IsConfigured() const { return this->Configured; } bool IsConfigured() const { return this->Configured; }
void SetConfigured(){ this->Configured = true; } void SetConfigured(){ this->Configured = true; }
@ -851,9 +846,12 @@ protected:
std::vector<std::string> HeaderFileExtensions; std::vector<std::string> HeaderFileExtensions;
std::string DefineFlags; std::string DefineFlags;
std::vector<cmValueWithOrigin> IncludeDirectoriesEntries; std::vector<std::string> IncludeDirectoriesEntries;
std::vector<cmValueWithOrigin> CompileOptionsEntries; std::vector<cmListFileBacktrace> IncludeDirectoriesEntryBacktraces;
std::vector<cmValueWithOrigin> CompileDefinitionsEntries; 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. // Track the value of the computed DEFINITIONS property.
void AddDefineFlag(const char*, std::string&); void AddDefineFlag(const char*, std::string&);

View File

@ -69,7 +69,7 @@ bool cmMessageCommand
++i; ++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) if (type != cmake::MESSAGE)
{ {

View File

@ -293,7 +293,7 @@ cmOutputConverter::ConvertToRelativePath(const std::vector<std::string>& local,
{ {
relative += "/"; relative += "/";
} }
relative += cmJoin(cmRange(remote).advance(common), "/"); relative += cmJoin(cmMakeRange(remote).advance(common), "/");
// Finally return the path. // Finally return the path.
return relative; return relative;

View File

@ -108,7 +108,7 @@ bool cmSetCommand
} }
// collect any values into a single semi-colon separated value list // 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) if (parentScope)
{ {

View File

@ -319,7 +319,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
} }
// Concatenate all the last arguments together. // 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. // Scan through the input for all matches.
std::string output; std::string output;
@ -365,7 +365,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
} }
// Concatenate all the last arguments together. // 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. // Scan through the input for all matches.
std::string output; std::string output;
@ -465,7 +465,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
} }
// Concatenate all the last arguments together. // 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. // Scan through the input for all matches.
std::string output; std::string output;
@ -665,7 +665,7 @@ bool cmStringCommand::HandleReplaceCommand(std::vector<std::string> const&
const std::string& replaceExpression = args[2]; const std::string& replaceExpression = args[2];
const std::string& variableName = args[3]; 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(), cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(),
replaceExpression.c_str()); replaceExpression.c_str());
@ -756,7 +756,7 @@ bool cmStringCommand::HandleAppendCommand(std::vector<std::string> const& args)
{ {
value = oldValue; 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()); this->Makefile->AddDefinition(variable, value.c_str());
return true; return true;
} }
@ -772,7 +772,7 @@ bool cmStringCommand
} }
std::string const& variableName = args[1]; 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()); this->Makefile->AddDefinition(variableName, value.c_str());
return true; return true;

View File

@ -402,13 +402,17 @@ void cmTarget::SetMakefile(cmMakefile* mf)
{ {
// Initialize the INCLUDE_DIRECTORIES property based on the current value // Initialize the INCLUDE_DIRECTORIES property based on the current value
// of the same directory property: // of the same directory property:
const std::vector<cmValueWithOrigin> parentIncludes = const cmStringRange parentIncludes =
this->Makefile->GetIncludeDirectoriesEntries(); this->Makefile->GetIncludeDirectoriesEntries();
const cmBacktraceRange parentIncludesBts =
this->Makefile->GetIncludeDirectoriesBacktraces();
for (std::vector<cmValueWithOrigin>::const_iterator it cmBacktraceRange::const_iterator btIt = parentIncludesBts.begin();
= parentIncludes.begin(); it != parentIncludes.end(); ++it) 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 = const std::set<std::string> parentSystemIncludes =
this->Makefile->GetSystemIncludeDirectories(); this->Makefile->GetSystemIncludeDirectories();
@ -416,13 +420,17 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(), this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(),
parentSystemIncludes.end()); parentSystemIncludes.end());
const std::vector<cmValueWithOrigin> parentOptions = const cmStringRange parentOptions =
this->Makefile->GetCompileOptionsEntries(); this->Makefile->GetCompileOptionsEntries();
const cmBacktraceRange parentOptionsBts =
this->Makefile->GetCompileOptionsBacktraces();
for (std::vector<cmValueWithOrigin>::const_iterator it btIt = parentOptionsBts.begin();
= parentOptions.begin(); it != parentOptions.end(); ++it) 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, void cmTarget::InsertInclude(std::string const& entry,
cmListFileBacktrace const& bt,
bool before) bool before)
{ {
cmGeneratorExpression ge(entry.Backtrace); cmGeneratorExpression ge(bt);
std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
= before ? this->Internal->IncludeDirectoriesEntries.begin() = before ? this->Internal->IncludeDirectoriesEntries.begin()
: this->Internal->IncludeDirectoriesEntries.end(); : this->Internal->IncludeDirectoriesEntries.end();
this->Internal->IncludeDirectoriesEntries.insert(position, this->Internal->IncludeDirectoriesEntries.insert(position,
new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value))); new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry)));
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry, void cmTarget::InsertCompileOption(std::string const& entry,
cmListFileBacktrace const& bt,
bool before) bool before)
{ {
cmGeneratorExpression ge(entry.Backtrace); cmGeneratorExpression ge(bt);
std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
= before ? this->Internal->CompileOptionsEntries.begin() = before ? this->Internal->CompileOptionsEntries.begin()
: this->Internal->CompileOptionsEntries.end(); : this->Internal->CompileOptionsEntries.end();
this->Internal->CompileOptionsEntries.insert(position, 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( 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::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(); propsString += " and the " + props.back();
std::ostringstream e; std::ostringstream e;

View File

@ -572,11 +572,14 @@ public:
std::vector<std::string> GetIncludeDirectories( std::vector<std::string> GetIncludeDirectories(
const std::string& config, const std::string& config,
const std::string& language) const; const std::string& language) const;
void InsertInclude(const cmValueWithOrigin &entry, void InsertInclude(std::string const& entry,
cmListFileBacktrace const& bt,
bool before = false); bool before = false);
void InsertCompileOption(const cmValueWithOrigin &entry, void InsertCompileOption(std::string const& entry,
cmListFileBacktrace const& bt,
bool before = false); bool before = false);
void InsertCompileDefinition(const cmValueWithOrigin &entry); void InsertCompileDefinition(std::string const& entry,
cmListFileBacktrace const& bt);
void AppendBuildInterfaceIncludes(); void AppendBuildInterfaceIncludes();

View File

@ -50,7 +50,6 @@ bool cmTargetCompileOptionsCommand
bool, bool) bool, bool)
{ {
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmValueWithOrigin entry(this->Join(content), lfbt); tgt->InsertCompileOption(this->Join(content), lfbt);
tgt->InsertCompileOption(entry);
return true; return true;
} }

View File

@ -72,8 +72,7 @@ bool cmTargetIncludeDirectoriesCommand
bool prepend, bool system) bool prepend, bool system)
{ {
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmValueWithOrigin entry(this->Join(content), lfbt); tgt->InsertInclude(this->Join(content), lfbt, prepend);
tgt->InsertInclude(entry, prepend);
if (system) if (system)
{ {
tgt->AddSystemIncludeDirectories(content); tgt->AddSystemIncludeDirectories(content);

View File

@ -335,14 +335,14 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Echo string // Echo string
else if (args[1] == "echo" ) 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; return 0;
} }
// Echo string no new line // Echo string no new line
else if (args[1] == "echo_append" ) else if (args[1] == "echo_append" )
{ {
std::cout << cmJoin(cmRange(args).advance(2), " "); std::cout << cmJoin(cmMakeRange(args).advance(2), " ");
return 0; return 0;
} }
@ -511,7 +511,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Clock command // Clock command
else if (args[1] == "time" && args.size() > 2) 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; clock_t clock_start, clock_finish;
time_t time_start, time_finish; time_t time_start, time_finish;
@ -572,7 +572,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 1; return 1;
} }
std::string command = cmWrap('"', cmRange(args).advance(3), '"', " "); std::string command =
cmWrap('"', cmMakeRange(args).advance(3), '"', " ");
int retval = 0; int retval = 0;
int timeout = 0; int timeout = 0;
if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &retval, if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &retval,