summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmAlgorithms.h84
-rw-r--r--Source/cmCMakePolicyCommand.cxx16
-rw-r--r--Source/cmExportCommand.cxx6
-rw-r--r--Source/cmFileCommand.cxx2
-rw-r--r--Source/cmFindBase.cxx4
-rw-r--r--Source/cmFunctionCommand.cxx2
-rw-r--r--Source/cmGlobalGenerator.cxx12
-rw-r--r--Source/cmListCommand.cxx12
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmMacroCommand.cxx2
-rw-r--r--Source/cmMakefile.cxx208
-rw-r--r--Source/cmMakefile.h25
-rw-r--r--Source/cmMessageCommand.cxx2
-rw-r--r--Source/cmOutputConverter.cxx2
-rw-r--r--Source/cmPolicies.cxx32
-rw-r--r--Source/cmPolicies.h4
-rw-r--r--Source/cmSetCommand.cxx2
-rw-r--r--Source/cmState.cxx312
-rw-r--r--Source/cmState.h32
-rw-r--r--Source/cmStringCommand.cxx12
-rw-r--r--Source/cmTarget.cxx65
-rw-r--r--Source/cmTarget.h11
-rw-r--r--Source/cmTargetCompileOptionsCommand.cxx3
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx3
-rw-r--r--Source/cmcmd.cxx9
26 files changed, 606 insertions, 260 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index ebceff9..f5c693a 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 3)
-set(CMake_VERSION_PATCH 20150721)
+set(CMake_VERSION_PATCH 20150727)
#set(CMake_VERSION_RC 1)
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index f117475..bda933b 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,11 +356,17 @@ 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());
}
+template <class Iter>
+std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it)
+{
+ return std::reverse_iterator<Iter>(it);
+}
+
#endif
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index 3c878bf..3ef6d35 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -93,6 +93,22 @@ bool cmCMakePolicyCommand::HandleSetMode(std::vector<std::string> const& args)
this->SetError("SET failed to set policy.");
return false;
}
+ if(args[1] == "CMP0001" &&
+ (status == cmPolicies::WARN || status == cmPolicies::OLD))
+ {
+ if(!(this->Makefile->GetState()
+ ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")))
+ {
+ // Set it to 2.4 because that is the last version where the
+ // variable had meaning.
+ this->Makefile->AddCacheDefinition
+ ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4",
+ "For backwards compatibility, what version of CMake "
+ "commands and "
+ "syntax should this version of CMake try to support.",
+ cmState::STRING);
+ }
+ }
return true;
}
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 43d26f9..96ea77b 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -177,6 +177,12 @@ bool cmExportCommand
this->SetError(e.str());
return false;
}
+ if (target->GetType() == cmTarget::UTILITY)
+ {
+ this->SetError("given custom target \"" + *currentTarget
+ + "\" which may not be exported.");
+ return false;
+ }
}
else
{
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 3d84f38..0daed66 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 add06a7..7959ffe 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 78853ce..c883ad7 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 88ac0bc..40a8586 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 f96b4a8..6041fb7 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 077d4d9..ca4d359 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 fa5a623..e4026b0 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 7c98970..57e33df 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -273,6 +273,38 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
}
}
+cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const
+{
+ return this->StateSnapshot.GetDirectory().GetIncludeDirectoriesEntries();
+}
+
+cmBacktraceRange cmMakefile::GetIncludeDirectoriesBacktraces() const
+{
+ return this->StateSnapshot.GetDirectory()
+ .GetIncludeDirectoriesEntryBacktraces();
+}
+
+cmStringRange cmMakefile::GetCompileOptionsEntries() const
+{
+ return this->StateSnapshot.GetDirectory().GetCompileOptionsEntries();
+}
+
+cmBacktraceRange cmMakefile::GetCompileOptionsBacktraces() const
+{
+ return this->StateSnapshot.GetDirectory().GetCompileOptionsEntryBacktraces();
+}
+
+cmStringRange cmMakefile::GetCompileDefinitionsEntries() const
+{
+ return this->StateSnapshot.GetDirectory().GetCompileDefinitionsEntries();
+}
+
+cmBacktraceRange cmMakefile::GetCompileDefinitionsBacktraces() const
+{
+ return this->StateSnapshot.GetDirectory()
+ .GetCompileDefinitionsEntryBacktraces();
+}
+
//----------------------------------------------------------------------------
cmListFileBacktrace cmMakefile::GetBacktrace() const
{
@@ -1438,7 +1470,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());
@@ -1533,29 +1565,13 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
// Initialize definitions with the closure of the parent scope.
this->Internal->InitializeDefinitions(parent);
+ this->StateSnapshot.InitializeFromParent();
+
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
this->GetCurrentSourceDirectory());
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->SystemIncludeDirectories = parent->SystemIncludeDirectories;
// define flags
@@ -1898,20 +1914,25 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
return;
}
- std::vector<cmValueWithOrigin>::iterator position =
- before ? this->IncludeDirectoriesEntries.begin()
- : this->IncludeDirectoriesEntries.end();
-
cmListFileBacktrace lfbt = this->GetBacktrace();
- cmValueWithOrigin entry(cmJoin(incs, ";"), lfbt);
- this->IncludeDirectoriesEntries.insert(position, entry);
+ std::string entryString = cmJoin(incs, ";");
+ if (before)
+ {
+ this->StateSnapshot.GetDirectory()
+ .PrependIncludeDirectoriesEntry(entryString, lfbt);
+ }
+ else
+ {
+ this->StateSnapshot.GetDirectory()
+ .AppendIncludeDirectoriesEntry(entryString, 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);
}
}
@@ -4130,37 +4151,35 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value)
{
if (prop == "INCLUDE_DIRECTORIES")
{
- this->IncludeDirectoriesEntries.clear();
if (!value)
{
+ this->StateSnapshot.GetDirectory().ClearIncludeDirectories();
return;
}
cmListFileBacktrace lfbt = this->GetBacktrace();
- this->IncludeDirectoriesEntries.push_back(
- cmValueWithOrigin(value, lfbt));
+ this->StateSnapshot.GetDirectory().SetIncludeDirectories(value, lfbt);
return;
}
if (prop == "COMPILE_OPTIONS")
{
- this->CompileOptionsEntries.clear();
if (!value)
{
+ this->StateSnapshot.GetDirectory().ClearCompileOptions();
return;
}
cmListFileBacktrace lfbt = this->GetBacktrace();
- this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt));
+ this->StateSnapshot.GetDirectory().SetCompileOptions(value, lfbt);
return;
}
if (prop == "COMPILE_DEFINITIONS")
{
- this->CompileDefinitionsEntries.clear();
if (!value)
{
+ this->StateSnapshot.GetDirectory().ClearCompileDefinitions();
return;
}
cmListFileBacktrace lfbt = this->GetBacktrace();
- cmValueWithOrigin entry(value, lfbt);
- this->CompileDefinitionsEntries.push_back(entry);
+ this->StateSnapshot.GetDirectory().SetCompileDefinitions(value, lfbt);
return;
}
@@ -4174,22 +4193,21 @@ void cmMakefile::AppendProperty(const std::string& prop,
if (prop == "INCLUDE_DIRECTORIES")
{
cmListFileBacktrace lfbt = this->GetBacktrace();
- this->IncludeDirectoriesEntries.push_back(
- cmValueWithOrigin(value, lfbt));
+ this->StateSnapshot.GetDirectory().AppendIncludeDirectoriesEntry(value,
+ lfbt);
return;
}
if (prop == "COMPILE_OPTIONS")
{
cmListFileBacktrace lfbt = this->GetBacktrace();
- this->CompileOptionsEntries.push_back(
- cmValueWithOrigin(value, lfbt));
+ this->StateSnapshot.GetDirectory().AppendCompileOptionsEntry(value, lfbt);
return;
}
if (prop == "COMPILE_DEFINITIONS")
{
cmListFileBacktrace lfbt = this->GetBacktrace();
- this->CompileDefinitionsEntries.push_back(
- cmValueWithOrigin(value, lfbt));
+ this->StateSnapshot.GetDirectory().AppendCompileDefinitionsEntry(value,
+ lfbt);
return;
}
@@ -4244,44 +4262,20 @@ 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->StateSnapshot.GetDirectory()
+ .GetIncludeDirectoriesEntries(), ";");
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->StateSnapshot.GetDirectory()
+ .GetCompileOptionsEntries(), ";");
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->StateSnapshot.GetDirectory()
+ .GetCompileDefinitionsEntries(), ";");
return output.c_str();
}
@@ -4753,53 +4747,30 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const
cmPolicies::PolicyStatus
cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
{
- // Get the current setting of the policy.
- cmPolicies::PolicyStatus cur = this->GetPolicyStatusInternal(id);
+ cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id);
- // If the policy is required to be set to NEW but is not, ignore the
- // current setting and tell the caller.
- if(cur != cmPolicies::NEW)
+ if(status == cmPolicies::REQUIRED_ALWAYS ||
+ status == cmPolicies::REQUIRED_IF_USED)
{
- if(cur == cmPolicies::REQUIRED_ALWAYS ||
- cur == cmPolicies::REQUIRED_IF_USED)
- {
- return cur;
- }
- cmPolicies::PolicyStatus def = cmPolicies::GetPolicyStatus(id);
- if(def == cmPolicies::REQUIRED_ALWAYS ||
- def == cmPolicies::REQUIRED_IF_USED)
- {
- return def;
- }
+ return status;
}
- // The current setting is okay.
- return cur;
-}
-
-//----------------------------------------------------------------------------
-cmPolicies::PolicyStatus
-cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) const
-{
- // Is the policy set in our stack?
- for(PolicyStackType::const_reverse_iterator psi = this->PolicyStack.rbegin();
- psi != this->PolicyStack.rend(); ++psi)
+ cmLocalGenerator* lg = this->LocalGenerator;
+ while(lg)
{
- if(psi->IsDefined(id))
+ cmMakefile const* mf = lg->GetMakefile();
+ for(PolicyStackType::const_reverse_iterator psi =
+ mf->PolicyStack.rbegin(); psi != mf->PolicyStack.rend(); ++psi)
{
- return psi->Get(id);
+ if(psi->IsDefined(id))
+ {
+ status = psi->Get(id);
+ return status;
+ }
}
+ lg = lg->GetParent();
}
-
- // If we have a parent directory, recurse up to it.
- if(this->LocalGenerator->GetParent())
- {
- cmMakefile* parent = this->LocalGenerator->GetParent()->GetMakefile();
- return parent->GetPolicyStatusInternal(id);
- }
-
- // The policy is not set. Use the default for this CMake version.
- return cmPolicies::GetPolicyStatus(id);
+ return status;
}
//----------------------------------------------------------------------------
@@ -4857,25 +4828,6 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
previous_was_weak = psi->Weak;
}
- // Special hook for presenting compatibility variable as soon as
- // the user requests it.
- if(id == cmPolicies::CMP0001 &&
- (status == cmPolicies::WARN || status == cmPolicies::OLD))
- {
- if(!(this->GetState()
- ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")))
- {
- // Set it to 2.4 because that is the last version where the
- // variable had meaning.
- this->AddCacheDefinition
- ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4",
- "For backwards compatibility, what version of CMake "
- "commands and "
- "syntax should this version of CMake try to support.",
- cmState::STRING);
- }
- }
-
return true;
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 2fc4d78..07342ea 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,10 +846,6 @@ protected:
std::vector<std::string> HeaderFileExtensions;
std::string DefineFlags;
- std::vector<cmValueWithOrigin> IncludeDirectoriesEntries;
- std::vector<cmValueWithOrigin> CompileOptionsEntries;
- std::vector<cmValueWithOrigin> CompileDefinitionsEntries;
-
// Track the value of the computed DEFINITIONS property.
void AddDefineFlag(const char*, std::string&);
void RemoveDefineFlag(const char*, std::string::size_type, std::string&);
@@ -938,8 +929,6 @@ private:
typedef std::vector<PolicyStackEntry> PolicyStackType;
PolicyStackType PolicyStack;
std::vector<PolicyStackType::size_type> PolicyBarriers;
- cmPolicies::PolicyStatus
- GetPolicyStatusInternal(cmPolicies::PolicyID id) const;
// CMP0053 == old
cmake::MessageType ExpandVariablesInStringOld(
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 0449c50..2854a82 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 91f3c0a..7be5b3f 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/cmPolicies.cxx b/Source/cmPolicies.cxx
index 5026893..3eb19bb 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -255,6 +255,22 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
{
return false;
}
+ if(pid == cmPolicies::CMP0001 &&
+ (status == cmPolicies::WARN || status == cmPolicies::OLD))
+ {
+ if(!(mf->GetState()
+ ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")))
+ {
+ // Set it to 2.4 because that is the last version where the
+ // variable had meaning.
+ mf->AddCacheDefinition
+ ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4",
+ "For backwards compatibility, what version of CMake "
+ "commands and "
+ "syntax should this version of CMake try to support.",
+ cmState::STRING);
+ }
+ }
}
}
else
@@ -356,14 +372,6 @@ cmPolicies::PolicyMap::Get(cmPolicies::PolicyID id) const
{
status = cmPolicies::NEW;
}
- else if (this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_ALWAYS])
- {
- status = cmPolicies::REQUIRED_ALWAYS;
- }
- else if (this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_IF_USED])
- {
- status = cmPolicies::REQUIRED_IF_USED;
- }
return status;
}
@@ -373,19 +381,13 @@ void cmPolicies::PolicyMap::Set(cmPolicies::PolicyID id,
this->Status[(POLICY_STATUS_COUNT * id) + OLD] = (status == OLD);
this->Status[(POLICY_STATUS_COUNT * id) + WARN] = (status == WARN);
this->Status[(POLICY_STATUS_COUNT * id) + NEW] = (status == NEW);
- this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_ALWAYS] =
- (status == REQUIRED_ALWAYS);
- this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_IF_USED] =
- (status == REQUIRED_IF_USED);
}
bool cmPolicies::PolicyMap::IsDefined(cmPolicies::PolicyID id) const
{
return this->Status[(POLICY_STATUS_COUNT * id) + OLD]
|| this->Status[(POLICY_STATUS_COUNT * id) + WARN]
- || this->Status[(POLICY_STATUS_COUNT * id) + NEW]
- || this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_ALWAYS]
- || this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_IF_USED];
+ || this->Status[(POLICY_STATUS_COUNT * id) + NEW];
}
bool cmPolicies::PolicyMap::IsEmpty() const
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 8a3c27d..b783701 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -12,7 +12,7 @@
#ifndef cmPolicies_h
#define cmPolicies_h
-#include "cmCustomCommand.h"
+#include "cmStandardIncludes.h"
#include <bitset>
@@ -244,7 +244,6 @@ public:
REQUIRED_IF_USED,
REQUIRED_ALWAYS ///< Issue an error unless user sets policy status to NEW.
};
-#define POLICY_STATUS_COUNT 5
/// Policy identifiers
enum PolicyID
@@ -288,6 +287,7 @@ public:
bool IsEmpty() const;
private:
+#define POLICY_STATUS_COUNT 3
std::bitset<cmPolicies::CMPCOUNT * POLICY_STATUS_COUNT> Status;
};
};
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index bf9f42c..306276b 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/cmState.cxx b/Source/cmState.cxx
index 9cbb841..d8f8306 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -28,6 +28,9 @@ struct cmState::SnapshotDataType
BuildSystemDirectory;
std::string EntryPointCommand;
long EntryPointLine;
+ std::vector<std::string>::size_type IncludeDirectoryPosition;
+ std::vector<std::string>::size_type CompileDefinitionsPosition;
+ std::vector<std::string>::size_type CompileOptionsPosition;
};
struct cmState::BuildsystemDirectoryStateType
@@ -44,6 +47,15 @@ struct cmState::BuildsystemDirectoryStateType
// safely by the build tools.
std::string RelativePathTopSource;
std::string RelativePathTopBinary;
+
+ std::vector<std::string> IncludeDirectories;
+ std::vector<cmListFileBacktrace> IncludeDirectoryBacktraces;
+
+ std::vector<std::string> CompileDefinitions;
+ std::vector<cmListFileBacktrace> CompileDefinitionsBacktraces;
+
+ std::vector<std::string> CompileOptions;
+ std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
};
cmState::cmState(cmake* cm)
@@ -228,7 +240,16 @@ cmState::Snapshot cmState::Reset()
this->GlobalProperties.clear();
this->PropertyDefinitions.clear();
- this->BuildsystemDirectory.Truncate();
+ {
+ cmLinkedTree<BuildsystemDirectoryStateType>::iterator it =
+ this->BuildsystemDirectory.Truncate();
+ it->IncludeDirectories.clear();
+ it->IncludeDirectoryBacktraces.clear();
+ it->CompileDefinitions.clear();
+ it->CompileDefinitionsBacktraces.clear();
+ it->CompileOptions.clear();
+ it->CompileOptionsBacktraces.clear();
+ }
PositionType pos = this->SnapshotData.Truncate();
this->ExecutionListFiles.Truncate();
@@ -698,6 +719,9 @@ cmState::Snapshot cmState::CreateBaseSnapshot()
this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root());
pos->ExecutionListFile =
this->ExecutionListFiles.Extend(this->ExecutionListFiles.Root());
+ pos->IncludeDirectoryPosition = 0;
+ pos->CompileDefinitionsPosition = 0;
+ pos->CompileOptionsPosition = 0;
return cmState::Snapshot(this, pos);
}
@@ -796,6 +820,13 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
PositionType pos = originSnapshot.Position;
PositionType prevPos = pos;
++prevPos;
+ prevPos->IncludeDirectoryPosition =
+ prevPos->BuildSystemDirectory->IncludeDirectories.size();
+ prevPos->CompileDefinitionsPosition =
+ prevPos->BuildSystemDirectory->CompileDefinitions.size();
+ prevPos->CompileOptionsPosition =
+ prevPos->BuildSystemDirectory->CompileOptions.size();
+
if (prevPos == this->SnapshotData.Root())
{
return Snapshot(this, prevPos);
@@ -803,6 +834,12 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
return Snapshot(this, originSnapshot.Position->CallStackParent);
}
+cmState::Snapshot::Snapshot(cmState* state)
+ : State(state)
+ , Position()
+{
+}
+
cmState::Snapshot::Snapshot(cmState* state, PositionType position)
: State(state),
Position(position)
@@ -943,6 +980,62 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const
return snapshot;
}
+static const std::string cmPropertySentinal = std::string();
+
+template<typename T, typename U, typename V>
+void InitializeContentFromParent(T& parentContent,
+ T& thisContent,
+ U& parentBacktraces,
+ U& thisBacktraces,
+ V& contentEndPosition)
+{
+ std::vector<std::string>::const_iterator parentBegin =
+ parentContent.begin();
+ std::vector<std::string>::const_iterator parentEnd =
+ parentContent.end();
+
+ std::vector<std::string>::const_reverse_iterator parentRbegin =
+ cmMakeReverseIterator(parentEnd);
+ std::vector<std::string>::const_reverse_iterator parentRend =
+ parentContent.rend();
+ parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal);
+ std::vector<std::string>::const_iterator parentIt = parentRbegin.base();
+
+ thisContent = std::vector<std::string>(parentIt, parentEnd);
+
+ std::vector<cmListFileBacktrace>::const_iterator btIt =
+ parentBacktraces.begin() + std::distance(parentBegin, parentIt);
+ std::vector<cmListFileBacktrace>::const_iterator btEnd =
+ parentBacktraces.end();
+
+ thisBacktraces = std::vector<cmListFileBacktrace>(btIt, btEnd);
+
+ contentEndPosition = thisContent.size();
+}
+
+void cmState::Snapshot::InitializeFromParent()
+{
+ PositionType parent = this->Position->DirectoryParent;
+
+ InitializeContentFromParent(parent->BuildSystemDirectory->IncludeDirectories,
+ this->Position->BuildSystemDirectory->IncludeDirectories,
+ parent->BuildSystemDirectory->IncludeDirectoryBacktraces,
+ this->Position->BuildSystemDirectory->IncludeDirectoryBacktraces,
+ this->Position->IncludeDirectoryPosition);
+
+ InitializeContentFromParent(parent->BuildSystemDirectory->CompileDefinitions,
+ this->Position->BuildSystemDirectory->CompileDefinitions,
+ parent->BuildSystemDirectory->CompileDefinitionsBacktraces,
+ this->Position->BuildSystemDirectory->CompileDefinitionsBacktraces,
+ this->Position->CompileDefinitionsPosition);
+
+ InitializeContentFromParent(parent->BuildSystemDirectory->CompileOptions,
+ this->Position->BuildSystemDirectory->CompileOptions,
+ parent->BuildSystemDirectory->CompileOptionsBacktraces,
+ this->Position->BuildSystemDirectory->CompileOptionsBacktraces,
+ this->Position->CompileOptionsPosition);
+}
+
cmState* cmState::Snapshot::GetState() const
{
return this->State;
@@ -960,3 +1053,220 @@ cmState::Directory::Directory(
{
}
+
+template <typename T, typename U>
+cmStringRange GetPropertyContent(T const& content, U contentEndPosition)
+{
+ std::vector<std::string>::const_iterator end =
+ content.begin() + contentEndPosition;
+
+ std::vector<std::string>::const_reverse_iterator rbegin =
+ cmMakeReverseIterator(end);
+ rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
+
+ return cmMakeRange(rbegin.base(), end);
+}
+
+template <typename T, typename U, typename V>
+cmBacktraceRange GetPropertyBacktraces(T const& content,
+ U const& backtraces,
+ V contentEndPosition)
+{
+ std::vector<std::string>::const_iterator entryEnd =
+ content.begin() + contentEndPosition;
+
+ std::vector<std::string>::const_reverse_iterator rbegin =
+ cmMakeReverseIterator(entryEnd);
+ rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
+
+ std::vector<cmListFileBacktrace>::const_iterator it =
+ backtraces.begin() + std::distance(content.begin(), rbegin.base());
+
+ std::vector<cmListFileBacktrace>::const_iterator end = backtraces.end();
+ return cmMakeRange(it, end);
+}
+
+template <typename T, typename U, typename V>
+void AppendEntry(T& content, U& backtraces, V& endContentPosition,
+ const std::string& vec, const cmListFileBacktrace& lfbt)
+{
+ assert(endContentPosition == content.size());
+
+ content.push_back(vec);
+ backtraces.push_back(lfbt);
+
+ endContentPosition = content.size();
+}
+
+template <typename T, typename U, typename V>
+void SetContent(T& content, U& backtraces, V& endContentPosition,
+ const std::string& vec, const cmListFileBacktrace& lfbt)
+{
+ assert(endContentPosition == content.size());
+
+ content.resize(content.size() + 2);
+ backtraces.resize(backtraces.size() + 2);
+
+ content.back() = vec;
+ backtraces.back() = lfbt;
+
+ endContentPosition = content.size();
+}
+
+template <typename T, typename U, typename V>
+void ClearContent(T& content, U& backtraces, V& endContentPosition)
+{
+ assert(endContentPosition == content.size());
+
+ content.resize(content.size() + 1);
+ backtraces.resize(backtraces.size() + 1);
+
+ endContentPosition = content.size();
+}
+
+cmStringRange
+cmState::Directory::GetIncludeDirectoriesEntries() const
+{
+ return GetPropertyContent(this->DirectoryState->IncludeDirectories,
+ this->Snapshot_.Position->IncludeDirectoryPosition);
+}
+
+cmBacktraceRange
+cmState::Directory::GetIncludeDirectoriesEntryBacktraces() const
+{
+ return GetPropertyBacktraces(this->DirectoryState->IncludeDirectories,
+ this->DirectoryState->IncludeDirectoryBacktraces,
+ this->Snapshot_.Position->IncludeDirectoryPosition);
+}
+
+void cmState::Directory::AppendIncludeDirectoriesEntry(
+ const std::string& vec, const cmListFileBacktrace& lfbt)
+{
+ AppendEntry(this->DirectoryState->IncludeDirectories,
+ this->DirectoryState->IncludeDirectoryBacktraces,
+ this->Snapshot_.Position->IncludeDirectoryPosition,
+ vec, lfbt);
+}
+
+void cmState::Directory::PrependIncludeDirectoriesEntry(
+ const std::string& vec, const cmListFileBacktrace& lfbt)
+{
+ std::vector<std::string>::iterator entryEnd =
+ this->DirectoryState->IncludeDirectories.begin()
+ + this->Snapshot_.Position->IncludeDirectoryPosition;
+
+ std::vector<std::string>::const_reverse_iterator rend =
+ this->DirectoryState->IncludeDirectories.rend();
+ std::vector<std::string>::reverse_iterator rbegin =
+ cmMakeReverseIterator(entryEnd);
+ std::vector<std::string>::const_reverse_iterator crbegin = rbegin;
+ crbegin = std::find(crbegin, rend, cmPropertySentinal);
+
+ std::vector<std::string>::const_iterator entryIt = crbegin.base();
+ std::vector<std::string>::const_iterator entryBegin =
+ this->DirectoryState->IncludeDirectories.begin();
+
+ std::vector<cmListFileBacktrace>::iterator btIt =
+ this->DirectoryState->IncludeDirectoryBacktraces.begin()
+ + std::distance(entryBegin, entryIt);
+
+ this->DirectoryState->IncludeDirectories.insert(rbegin.base(), vec);
+ this->DirectoryState->IncludeDirectoryBacktraces.insert(btIt, lfbt);
+
+ this->Snapshot_.Position->IncludeDirectoryPosition =
+ this->DirectoryState->IncludeDirectories.size();
+}
+
+void cmState::Directory::SetIncludeDirectories(
+ const std::string& vec, const cmListFileBacktrace& lfbt)
+{
+ SetContent(this->DirectoryState->IncludeDirectories,
+ this->DirectoryState->IncludeDirectoryBacktraces,
+ this->Snapshot_.Position->IncludeDirectoryPosition,
+ vec, lfbt);
+}
+
+void cmState::Directory::ClearIncludeDirectories()
+{
+ ClearContent(this->DirectoryState->IncludeDirectories,
+ this->DirectoryState->IncludeDirectoryBacktraces,
+ this->Snapshot_.Position->IncludeDirectoryPosition);
+}
+
+cmStringRange cmState::Directory::GetCompileDefinitionsEntries() const
+{
+ return GetPropertyContent(this->DirectoryState->CompileDefinitions,
+ this->Snapshot_.Position->CompileDefinitionsPosition);
+}
+
+cmBacktraceRange
+cmState::Directory::GetCompileDefinitionsEntryBacktraces() const
+{
+ return GetPropertyBacktraces(this->DirectoryState->CompileDefinitions,
+ this->DirectoryState->CompileDefinitionsBacktraces,
+ this->Snapshot_.Position->CompileDefinitionsPosition);
+}
+
+void cmState::Directory::AppendCompileDefinitionsEntry(const std::string& vec,
+ const cmListFileBacktrace& lfbt)
+{
+ AppendEntry(this->DirectoryState->CompileDefinitions,
+ this->DirectoryState->CompileDefinitionsBacktraces,
+ this->Snapshot_.Position->CompileDefinitionsPosition,
+ vec, lfbt);
+}
+
+void cmState::Directory::SetCompileDefinitions(const std::string& vec,
+ const cmListFileBacktrace& lfbt)
+{
+ SetContent(this->DirectoryState->CompileDefinitions,
+ this->DirectoryState->CompileDefinitionsBacktraces,
+ this->Snapshot_.Position->CompileDefinitionsPosition,
+ vec, lfbt);
+}
+
+void cmState::Directory::ClearCompileDefinitions()
+{
+ ClearContent(this->DirectoryState->CompileDefinitions,
+ this->DirectoryState->CompileDefinitionsBacktraces,
+ this->Snapshot_.Position->CompileDefinitionsPosition);
+}
+
+cmStringRange cmState::Directory::GetCompileOptionsEntries() const
+{
+ return GetPropertyContent(this->DirectoryState->CompileOptions,
+ this->Snapshot_.Position->CompileOptionsPosition);
+}
+
+cmBacktraceRange cmState::Directory::GetCompileOptionsEntryBacktraces() const
+{
+ return GetPropertyBacktraces(this->DirectoryState->CompileOptions,
+ this->DirectoryState->CompileOptionsBacktraces,
+ this->Snapshot_.Position->CompileOptionsPosition);
+}
+
+void
+cmState::Directory::AppendCompileOptionsEntry(const std::string& vec,
+ const cmListFileBacktrace& lfbt)
+{
+ AppendEntry(this->DirectoryState->CompileOptions,
+ this->DirectoryState->CompileOptionsBacktraces,
+ this->Snapshot_.Position->CompileOptionsPosition,
+ vec, lfbt);
+}
+
+void cmState::Directory::SetCompileOptions(const std::string& vec,
+ const cmListFileBacktrace& lfbt)
+{
+ SetContent(this->DirectoryState->CompileOptions,
+ this->DirectoryState->CompileOptionsBacktraces,
+ this->Snapshot_.Position->CompileOptionsPosition,
+ vec, lfbt);
+}
+
+void cmState::Directory::ClearCompileOptions()
+{
+ ClearContent(this->DirectoryState->CompileOptions,
+ this->DirectoryState->CompileOptionsBacktraces,
+ this->Snapshot_.Position->CompileOptionsPosition);
+}
diff --git a/Source/cmState.h b/Source/cmState.h
index acd23a5..0d5300f 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -16,6 +16,7 @@
#include "cmPropertyDefinitionMap.h"
#include "cmPropertyMap.h"
#include "cmLinkedTree.h"
+#include "cmAlgorithms.h"
class cmake;
class cmCommand;
@@ -43,7 +44,8 @@ public:
class Snapshot {
public:
- Snapshot(cmState* state = 0, PositionType position = PositionType());
+ Snapshot(cmState* state = 0);
+ Snapshot(cmState* state, PositionType position);
void SetListFile(std::string const& listfile);
@@ -55,6 +57,8 @@ public:
Snapshot GetBuildsystemDirectoryParent() const;
Snapshot GetCallStackParent() const;
+ void InitializeFromParent();
+
cmState* GetState() const;
Directory GetDirectory() const;
@@ -86,6 +90,32 @@ public:
void SetRelativePathTopSource(const char* dir);
void SetRelativePathTopBinary(const char* dir);
+ cmStringRange GetIncludeDirectoriesEntries() const;
+ cmBacktraceRange GetIncludeDirectoriesEntryBacktraces() const;
+ void AppendIncludeDirectoriesEntry(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void PrependIncludeDirectoriesEntry(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void SetIncludeDirectories(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void ClearIncludeDirectories();
+
+ cmStringRange GetCompileDefinitionsEntries() const;
+ cmBacktraceRange GetCompileDefinitionsEntryBacktraces() const;
+ void AppendCompileDefinitionsEntry(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void SetCompileDefinitions(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void ClearCompileDefinitions();
+
+ cmStringRange GetCompileOptionsEntries() const;
+ cmBacktraceRange GetCompileOptionsEntryBacktraces() const;
+ void AppendCompileOptionsEntry(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void SetCompileOptions(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void ClearCompileOptions();
+
private:
void ComputeRelativePathTopSource();
void ComputeRelativePathTopBinary();
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index efc1f16..649fb39 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 46e9ed4..8520e29 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)));
}
//----------------------------------------------------------------------------
@@ -2959,6 +2970,8 @@ const char *cmTarget::GetProperty(const std::string& prop,
MAKE_STATIC_PROP(COMPILE_DEFINITIONS);
MAKE_STATIC_PROP(IMPORTED);
MAKE_STATIC_PROP(NAME);
+ MAKE_STATIC_PROP(BINARY_DIR);
+ MAKE_STATIC_PROP(SOURCE_DIR);
MAKE_STATIC_PROP(SOURCES);
#undef MAKE_STATIC_PROP
if(specialProps.empty())
@@ -2971,6 +2984,8 @@ const char *cmTarget::GetProperty(const std::string& prop,
specialProps.insert(propCOMPILE_DEFINITIONS);
specialProps.insert(propIMPORTED);
specialProps.insert(propNAME);
+ specialProps.insert(propBINARY_DIR);
+ specialProps.insert(propSOURCE_DIR);
specialProps.insert(propSOURCES);
}
if(specialProps.count(prop))
@@ -3053,6 +3068,14 @@ const char *cmTarget::GetProperty(const std::string& prop,
{
return this->GetName().c_str();
}
+ else if (prop == propBINARY_DIR)
+ {
+ return this->GetMakefile()->GetCurrentBinaryDirectory();
+ }
+ else if (prop == propSOURCE_DIR)
+ {
+ return this->GetMakefile()->GetCurrentSourceDirectory();
+ }
else if(prop == propSOURCES)
{
if (this->Internal->SourceEntries.empty())
@@ -6674,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 1920312..f9bcb05 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 a85153d..8e86f0f 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 24500db..7824c89 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 63838b4..71f47f3 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,