summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmMakefile.cxx147
-rw-r--r--Source/cmMakefile.h3
-rw-r--r--Source/cmState.cxx163
-rw-r--r--Source/cmState.h9
4 files changed, 180 insertions, 142 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 3069218..2296d5a 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4075,152 +4075,28 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
void cmMakefile::SetProperty(const std::string& prop, const char* value)
{
- if (prop == "INCLUDE_DIRECTORIES")
- {
- if (!value)
- {
- this->StateSnapshot.GetDirectory().ClearIncludeDirectories();
- return;
- }
- cmListFileBacktrace lfbt = this->GetBacktrace();
- this->StateSnapshot.GetDirectory().SetIncludeDirectories(value, lfbt);
- return;
- }
- if (prop == "COMPILE_OPTIONS")
- {
- if (!value)
- {
- this->StateSnapshot.GetDirectory().ClearCompileOptions();
- return;
- }
- cmListFileBacktrace lfbt = this->GetBacktrace();
- this->StateSnapshot.GetDirectory().SetCompileOptions(value, lfbt);
- return;
- }
- if (prop == "COMPILE_DEFINITIONS")
- {
- if (!value)
- {
- this->StateSnapshot.GetDirectory().ClearCompileDefinitions();
- return;
- }
- cmListFileBacktrace lfbt = this->GetBacktrace();
- this->StateSnapshot.GetDirectory().SetCompileDefinitions(value, lfbt);
- return;
- }
-
- this->Properties.SetProperty(prop, value);
+ cmListFileBacktrace lfbt = this->GetBacktrace();
+ this->StateSnapshot.GetDirectory().SetProperty(prop, value, lfbt);
}
void cmMakefile::AppendProperty(const std::string& prop,
const char* value,
bool asString)
{
- if (prop == "INCLUDE_DIRECTORIES")
- {
- cmListFileBacktrace lfbt = this->GetBacktrace();
- this->StateSnapshot.GetDirectory().AppendIncludeDirectoriesEntry(value,
- lfbt);
- return;
- }
- if (prop == "COMPILE_OPTIONS")
- {
- cmListFileBacktrace lfbt = this->GetBacktrace();
- this->StateSnapshot.GetDirectory().AppendCompileOptionsEntry(value, lfbt);
- return;
- }
- if (prop == "COMPILE_DEFINITIONS")
- {
- cmListFileBacktrace lfbt = this->GetBacktrace();
- this->StateSnapshot.GetDirectory().AppendCompileDefinitionsEntry(value,
- lfbt);
- return;
- }
-
- this->Properties.AppendProperty(prop, value, asString);
+ cmListFileBacktrace lfbt = this->GetBacktrace();
+ this->StateSnapshot.GetDirectory().AppendProperty(prop, value,
+ asString, lfbt);
}
const char *cmMakefile::GetProperty(const std::string& prop) const
{
- const bool chain = this->GetState()->
- IsPropertyChained(prop, cmProperty::DIRECTORY);
- return this->GetProperty(prop, chain);
+ return this->StateSnapshot.GetDirectory().GetProperty(prop);
}
const char *cmMakefile::GetProperty(const std::string& prop,
bool chain) const
{
- // watch for specific properties
- static std::string output;
- output = "";
- if (prop == "PARENT_DIRECTORY")
- {
- cmState::Snapshot parent =
- this->StateSnapshot.GetBuildsystemDirectoryParent();
- if(parent.IsValid())
- {
- return parent.GetDirectory().GetCurrentSource();
- }
- return "";
- }
- else if (prop == "LISTFILE_STACK")
- {
- std::vector<std::string> listFiles;
- cmState::Snapshot snp = this->StateSnapshot;
- while (snp.IsValid())
- {
- listFiles.push_back(snp.GetExecutionListFile());
- snp = snp.GetCallStackParent();
- }
- std::reverse(listFiles.begin(), listFiles.end());
- output = cmJoin(listFiles, ";");
- return output.c_str();
- }
- else if ( prop == "CACHE_VARIABLES" )
- {
- output = cmJoin(this->GetState()->GetCacheEntryKeys(), ";");
- return output.c_str();
- }
- else if (prop == "VARIABLES")
- {
- std::vector<std::string> res = this->StateSnapshot.ClosureKeys();
- std::vector<std::string> cacheKeys = this->GetState()->GetCacheEntryKeys();
- res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
- std::sort(res.begin(), res.end());
- output = cmJoin(res, ";");
- return output.c_str();
- }
- else if (prop == "INCLUDE_DIRECTORIES")
- {
- output = cmJoin(this->StateSnapshot.GetDirectory()
- .GetIncludeDirectoriesEntries(), ";");
- return output.c_str();
- }
- else if (prop == "COMPILE_OPTIONS")
- {
- output = cmJoin(this->StateSnapshot.GetDirectory()
- .GetCompileOptionsEntries(), ";");
- return output.c_str();
- }
- else if (prop == "COMPILE_DEFINITIONS")
- {
- output = cmJoin(this->StateSnapshot.GetDirectory()
- .GetCompileDefinitionsEntries(), ";");
- return output.c_str();
- }
-
- const char *retVal = this->Properties.GetPropertyValue(prop);
- if (!retVal && chain)
- {
- if(this->LocalGenerator->GetParent())
- {
- return this->LocalGenerator->GetParent()->GetMakefile()->
- GetProperty(prop, chain);
- }
- return this->GetState()->GetGlobalProperty(prop);
- }
-
- return retVal;
+ return this->StateSnapshot.GetDirectory().GetProperty(prop, chain);
}
bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
@@ -4230,14 +4106,7 @@ bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
std::vector<std::string> cmMakefile::GetPropertyKeys() const
{
- std::vector<std::string> keys;
- keys.reserve(this->Properties.size());
- for(cmPropertyMap::const_iterator it = this->Properties.begin();
- it != this->Properties.end(); ++it)
- {
- keys.push_back(it->first);
- }
- return keys;
+ return this->StateSnapshot.GetDirectory().GetPropertyKeys();
}
cmTarget* cmMakefile::FindTarget(const std::string& name,
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 9f455cc..055170a 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -14,7 +14,6 @@
#include "cmExecutionStatus.h"
#include "cmListFileCache.h"
-#include "cmPropertyMap.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmNewLineStyle.h"
@@ -903,8 +902,6 @@ private:
std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
- cmPropertyMap Properties;
-
std::vector<cmCommandContext const*> ContextStack;
std::vector<cmExecutionStatus*> ExecutionStatusStack;
friend class cmMakefileCall;
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 336ff78..53fdae0 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -74,6 +74,8 @@ struct cmState::BuildsystemDirectoryStateType
std::vector<std::string> CompileOptions;
std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
+
+ cmPropertyMap Properties;
};
cmState::cmState(cmake* cm)
@@ -271,6 +273,7 @@ cmState::Snapshot cmState::Reset()
it->CompileOptions.clear();
it->CompileOptionsBacktraces.clear();
it->DirectoryEnd = pos;
+ it->Properties.clear();
}
this->PolicyStack.Clear();
@@ -1538,3 +1541,163 @@ bool cmState::Snapshot::StrictWeakOrder::operator()(
{
return lhs.Position.StrictWeakOrdered(rhs.Position);
}
+
+void cmState::Directory::SetProperty(const std::string& prop,
+ const char* value,
+ cmListFileBacktrace lfbt)
+{
+ if (prop == "INCLUDE_DIRECTORIES")
+ {
+ if (!value)
+ {
+ this->ClearIncludeDirectories();
+ return;
+ }
+ this->SetIncludeDirectories(value, lfbt);
+ return;
+ }
+ if (prop == "COMPILE_OPTIONS")
+ {
+ if (!value)
+ {
+ this->ClearCompileOptions();
+ return;
+ }
+ this->SetCompileOptions(value, lfbt);
+ return;
+ }
+ if (prop == "COMPILE_DEFINITIONS")
+ {
+ if (!value)
+ {
+ this->ClearCompileDefinitions();
+ return;
+ }
+ this->SetCompileDefinitions(value, lfbt);
+ return;
+ }
+
+ this->DirectoryState->Properties.SetProperty(prop, value);
+}
+
+void cmState::Directory::AppendProperty(const std::string& prop,
+ const char* value,
+ bool asString,
+ cmListFileBacktrace lfbt)
+{
+ if (prop == "INCLUDE_DIRECTORIES")
+ {
+ this->AppendIncludeDirectoriesEntry(value, lfbt);
+ return;
+ }
+ if (prop == "COMPILE_OPTIONS")
+ {
+ this->AppendCompileOptionsEntry(value, lfbt);
+ return;
+ }
+ if (prop == "COMPILE_DEFINITIONS")
+ {
+ this->AppendCompileDefinitionsEntry(value, lfbt);
+ return;
+ }
+
+ this->DirectoryState->Properties.AppendProperty(prop, value, asString);
+}
+
+const char*cmState::Directory::GetProperty(const std::string& prop) const
+{
+ const bool chain = this->Snapshot_.State->
+ IsPropertyChained(prop, cmProperty::DIRECTORY);
+ return this->GetProperty(prop, chain);
+}
+
+const char*
+cmState::Directory::GetProperty(const std::string& prop, bool chain) const
+{
+ static std::string output;
+ output = "";
+ if (prop == "PARENT_DIRECTORY")
+ {
+ cmState::Snapshot parent =
+ this->Snapshot_.GetBuildsystemDirectoryParent();
+ if(parent.IsValid())
+ {
+ return parent.GetDirectory().GetCurrentSource();
+ }
+ return "";
+ }
+ else if (prop == "LISTFILE_STACK")
+ {
+ std::vector<std::string> listFiles;
+ cmState::Snapshot snp = this->Snapshot_;
+ while (snp.IsValid())
+ {
+ listFiles.push_back(snp.GetExecutionListFile());
+ snp = snp.GetCallStackParent();
+ }
+ std::reverse(listFiles.begin(), listFiles.end());
+ output = cmJoin(listFiles, ";");
+ return output.c_str();
+ }
+ else if ( prop == "CACHE_VARIABLES" )
+ {
+ output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";");
+ return output.c_str();
+ }
+ else if (prop == "VARIABLES")
+ {
+ std::vector<std::string> res = this->Snapshot_.ClosureKeys();
+ std::vector<std::string> cacheKeys =
+ this->Snapshot_.State->GetCacheEntryKeys();
+ res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
+ std::sort(res.begin(), res.end());
+ output = cmJoin(res, ";");
+ return output.c_str();
+ }
+ else if (prop == "INCLUDE_DIRECTORIES")
+ {
+ output = cmJoin(this->GetIncludeDirectoriesEntries(), ";");
+ return output.c_str();
+ }
+ else if (prop == "COMPILE_OPTIONS")
+ {
+ output = cmJoin(this->GetCompileOptionsEntries(), ";");
+ return output.c_str();
+ }
+ else if (prop == "COMPILE_DEFINITIONS")
+ {
+ output = cmJoin(this->GetCompileDefinitionsEntries(), ";");
+ return output.c_str();
+ }
+
+ const char *retVal = this->DirectoryState->Properties.GetPropertyValue(prop);
+ if (!retVal && chain)
+ {
+ Snapshot parentSnapshot = this->Snapshot_.GetBuildsystemDirectoryParent();
+ if (parentSnapshot.IsValid())
+ {
+ return parentSnapshot.GetDirectory().GetProperty(prop, chain);
+ }
+ return this->Snapshot_.State->GetGlobalProperty(prop);
+ }
+
+ return retVal;
+}
+
+bool cmState::Directory::GetPropertyAsBool(const std::string& prop) const
+{
+ return cmSystemTools::IsOn(this->GetProperty(prop));
+}
+
+std::vector<std::string> cmState::Directory::GetPropertyKeys() const
+{
+ std::vector<std::string> keys;
+ keys.reserve(this->DirectoryState->Properties.size());
+ for(cmPropertyMap::const_iterator it =
+ this->DirectoryState->Properties.begin();
+ it != this->DirectoryState->Properties.end(); ++it)
+ {
+ keys.push_back(it->first);
+ }
+ return keys;
+}
diff --git a/Source/cmState.h b/Source/cmState.h
index 86945f6..e503cd2 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -146,6 +146,15 @@ public:
cmListFileBacktrace const& lfbt);
void ClearCompileOptions();
+ void SetProperty(const std::string& prop, const char *value,
+ cmListFileBacktrace lfbt);
+ void AppendProperty(const std::string& prop, const char *value,
+ bool asString, cmListFileBacktrace lfbt);
+ const char *GetProperty(const std::string& prop) const;
+ const char *GetProperty(const std::string& prop, bool chain) const;
+ bool GetPropertyAsBool(const std::string& prop) const;
+ std::vector<std::string> GetPropertyKeys() const;
+
private:
void ComputeRelativePathTopSource();
void ComputeRelativePathTopBinary();