summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx326
1 files changed, 215 insertions, 111 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 7c74a0f..63dbe27 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -146,7 +146,7 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars();
- this->GeneratingBuildSystem = false;
+ this->Configured = false;
this->SuppressWatches = false;
// Setup the default include file regular expression (match everything).
@@ -213,8 +213,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
#endif
- this->Properties.SetCMakeInstance(this->GetCMakeInstance());
-
{
const char* dir = this->GetCMakeInstance()->GetHomeDirectory();
this->AddDefinition("CMAKE_SOURCE_DIR", dir);
@@ -277,7 +275,21 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
//----------------------------------------------------------------------------
cmListFileBacktrace cmMakefile::GetBacktrace() const
{
- cmListFileBacktrace backtrace(this->GetLocalGenerator());
+ cmListFileBacktrace backtrace(this->StateSnapshot);
+ for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin();
+ i != this->CallStack.rend(); ++i)
+ {
+ backtrace.Append(*i->Context);
+ }
+ return backtrace;
+}
+
+//----------------------------------------------------------------------------
+cmListFileBacktrace
+cmMakefile::GetBacktrace(cmListFileContext const& lfc) const
+{
+ cmListFileBacktrace backtrace(this->StateSnapshot);
+ backtrace.Append(lfc);
for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin();
i != this->CallStack.rend(); ++i)
{
@@ -519,8 +531,10 @@ bool cmMakefile::ProcessBuildsystemFile(const char* listfile)
{
this->AddDefinition("CMAKE_PARENT_LIST_FILE", listfile);
std::string curSrc = this->GetCurrentSourceDirectory();
- return this->ReadListFile(listfile, true,
- curSrc == this->GetHomeDirectory());
+ bool result = this->ReadListFile(listfile, true,
+ curSrc == this->GetHomeDirectory());
+ this->EnforceDirectoryLevelRules();
+ return result;
}
bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope)
@@ -619,13 +633,6 @@ bool cmMakefile::ReadListFileInternal(const char* filenametoread,
}
}
- // If this is the directory-level CMakeLists.txt file then perform
- // some extra checks.
- if(this->ListFileStack.size() == 1)
- {
- this->EnforceDirectoryLevelRules();
- }
-
return true;
}
@@ -1476,10 +1483,8 @@ void cmMakefile::AddLinkDirectory(const std::string& dir)
}
}
-void cmMakefile::InitializeFromParent()
+void cmMakefile::InitializeFromParent(cmMakefile* parent)
{
- cmMakefile *parent = this->LocalGenerator->GetParent()->GetMakefile();
-
// Initialize definitions with the closure of the parent scope.
this->Internal->InitializeDefinitions(parent);
@@ -1553,10 +1558,118 @@ void cmMakefile::InitializeFromParent()
this->ImportedTargets = parent->ImportedTargets;
}
-void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2)
+void cmMakefile::PushFunctionScope(const cmPolicies::PolicyMap& pm)
+{
+ this->Internal->PushDefinitions();
+
+ this->PushLoopBlockBarrier();
+
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ this->GetGlobalGenerator()->GetFileLockPool().PushFunctionScope();
+#endif
+
+ this->PushFunctionBlockerBarrier();
+
+ this->PushPolicy(true, pm);
+ this->PushPolicyBarrier();
+}
+
+void cmMakefile::PopFunctionScope(bool reportError)
+{
+ this->PopPolicyBarrier(reportError);
+ this->PopPolicy();
+
+ this->PopFunctionBlockerBarrier(reportError);
+
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ this->GetGlobalGenerator()->GetFileLockPool().PopFunctionScope();
+#endif
+
+ this->PopLoopBlockBarrier();
+
+ this->CheckForUnusedVariables();
+
+ this->Internal->PopDefinitions();
+}
+
+void cmMakefile::PushMacroScope(const cmPolicies::PolicyMap& pm)
+{
+ this->PushFunctionBlockerBarrier();
+
+ this->PushPolicy(true, pm);
+ this->PushPolicyBarrier();
+}
+
+void cmMakefile::PopMacroScope(bool reportError)
+{
+ this->PopPolicyBarrier(reportError);
+ this->PopPolicy();
+
+ this->PopFunctionBlockerBarrier(reportError);
+}
+
+//----------------------------------------------------------------------------
+class cmMakefileCurrent
+{
+ cmGlobalGenerator* GG;
+ cmMakefile* MF;
+ cmState::Snapshot Snapshot;
+public:
+ cmMakefileCurrent(cmMakefile* mf)
+ {
+ this->GG = mf->GetGlobalGenerator();
+ this->MF = this->GG->GetCurrentMakefile();
+ this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot();
+ this->GG->GetCMakeInstance()->SetCurrentSnapshot(
+ this->GG->GetCMakeInstance()->GetCurrentSnapshot());
+ this->GG->SetCurrentMakefile(mf);
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ this->GG->GetFileLockPool().PushFileScope();
+#endif
+ }
+ ~cmMakefileCurrent()
+ {
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ this->GG->GetFileLockPool().PopFileScope();
+#endif
+ this->GG->SetCurrentMakefile(this->MF);
+ this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot);
+ }
+};
+
+//----------------------------------------------------------------------------
+void cmMakefile::Configure()
+{
+ cmMakefileCurrent cmf(this);
+
+ // make sure the CMakeFiles dir is there
+ std::string filesDir = this->StateSnapshot.GetCurrentBinaryDirectory();
+ filesDir += cmake::GetCMakeFilesDirectory();
+ cmSystemTools::MakeDirectory(filesDir.c_str());
+
+ std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory();
+ currentStart += "/CMakeLists.txt";
+ assert(cmSystemTools::FileExists(currentStart.c_str(), true));
+ this->ProcessBuildsystemFile(currentStart.c_str());
+
+ // at the end handle any old style subdirs
+ std::vector<cmMakefile*> subdirs = this->UnConfiguredDirectories;
+
+ // for each subdir recurse
+ std::vector<cmMakefile*>::iterator sdi = subdirs.begin();
+ for (; sdi != subdirs.end(); ++sdi)
+ {
+ this->ConfigureSubDirectory(*sdi);
+ }
+
+ this->AddCMakeDependFilesFromUser();
+ this->SetConfigured();
+}
+
+void cmMakefile::ConfigureSubDirectory(cmMakefile *mf)
{
- lg2->GetMakefile()->InitializeFromParent();
- std::string currentStart = lg2->GetMakefile()->GetCurrentSourceDirectory();
+ mf->InitializeFromParent(this);
+ std::string currentStart = mf->GetCurrentSourceDirectory();
if (this->GetCMakeInstance()->GetDebugOutput())
{
std::string msg=" Entering ";
@@ -1594,11 +1707,12 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2)
// NEW behavior prints the error.
this->IssueMessage(cmake::FATAL_ERROR, e.str());
}
- lg2->SetConfiguredCMP0014(true);
+ mf->SetConfigured();
return;
}
// finally configure the subdir
- lg2->Configure();
+ mf->Configure();
+
if (this->GetCMakeInstance()->GetDebugOutput())
{
std::string msg=" Returning to ";
@@ -1619,24 +1733,30 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
}
cmState::Snapshot newSnapshot = this->GetState()
- ->CreateSnapshot(this->StateSnapshot);
+ ->CreateBuildsystemDirectorySnapshot(this->StateSnapshot);
// create a new local generator and set its parent
cmLocalGenerator *lg2 = this->GetGlobalGenerator()
->MakeLocalGenerator(newSnapshot, this->LocalGenerator);
this->GetGlobalGenerator()->AddLocalGenerator(lg2);
+ cmMakefile* subMf = lg2->GetMakefile();
+
// set the subdirs start dirs
- lg2->GetMakefile()->SetCurrentSourceDirectory(srcPath);
- lg2->GetMakefile()->SetCurrentBinaryDirectory(binPath);
+ subMf->SetCurrentSourceDirectory(srcPath);
+ subMf->SetCurrentBinaryDirectory(binPath);
if(excludeFromAll)
{
- lg2->GetMakefile()->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
if (immediate)
{
- this->ConfigureSubDirectory(lg2);
+ this->ConfigureSubDirectory(subMf);
+ }
+ else
+ {
+ this->UnConfiguredDirectories.push_back(subMf);
}
}
@@ -2116,25 +2236,10 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
return;
}
// build the whole source group path
- const char* fullname = sg->GetFullName();
- cmGlobalGenerator* gg = this->GetGlobalGenerator();
- if(strlen(fullname))
- {
- std::string guidName = "SG_Filter_";
- guidName += fullname;
- gg->CreateGUID(guidName);
- }
for(++i; i<=lastElement; ++i)
{
sg->AddChild(cmSourceGroup(name[i].c_str(), 0, sg->GetFullName()));
sg = sg->LookupChild(name[i].c_str());
- fullname = sg->GetFullName();
- if(strlen(fullname))
- {
- std::string guidName = "SG_Filter_";
- guidName += fullname;
- gg->CreateGUID(guidName);
- }
}
sg->SetGroupRegex(regex);
@@ -2390,18 +2495,11 @@ const char* cmMakefile::GetSafeDefinition(const std::string& def) const
return ret;
}
-std::vector<std::string> cmMakefile
-::GetDefinitions(int cacheonly /* = 0 */) const
+std::vector<std::string> cmMakefile::GetDefinitions() const
{
- std::vector<std::string> res;
- if ( !cacheonly )
- {
- res = this->Internal->ClosureKeys();
- }
- std::vector<std::string> cacheKeys =
- this->GetState()->GetCacheEntryKeys();
+ std::vector<std::string> res = this->Internal->ClosureKeys();
+ std::vector<std::string> cacheKeys = this->GetState()->GetCacheEntryKeys();
res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
-
std::sort(res.begin(), res.end());
return res;
}
@@ -3982,7 +4080,7 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value)
}
}
- this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY);
+ this->Properties.SetProperty(prop, value);
}
void cmMakefile::AppendProperty(const std::string& prop,
@@ -4022,23 +4120,26 @@ void cmMakefile::AppendProperty(const std::string& prop,
return;
}
- this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString);
+ this->Properties.AppendProperty(prop, value, asString);
}
const char *cmMakefile::GetProperty(const std::string& prop) const
{
- return this->GetProperty(prop, cmProperty::DIRECTORY);
+ const bool chain = this->GetState()->
+ IsPropertyChained(prop, cmProperty::DIRECTORY);
+ return this->GetProperty(prop, chain);
}
const char *cmMakefile::GetProperty(const std::string& prop,
- cmProperty::ScopeType scope) const
+ bool chain) const
{
// watch for specific properties
static std::string output;
output = "";
if (prop == "PARENT_DIRECTORY")
{
- cmState::Snapshot parent = this->StateSnapshot.GetParent();
+ cmState::Snapshot parent =
+ this->StateSnapshot.GetBuildsystemDirectoryParent();
if(parent.IsValid())
{
return parent.GetCurrentSourceDirectory();
@@ -4055,36 +4156,20 @@ const char *cmMakefile::GetProperty(const std::string& prop,
output = cmJoin(this->ListFileStack, ";");
return output.c_str();
}
- else if (prop == "VARIABLES" || prop == "CACHE_VARIABLES")
+ else if ( prop == "CACHE_VARIABLES" )
{
- int cacheonly = 0;
- if ( prop == "CACHE_VARIABLES" )
- {
- cacheonly = 1;
- }
- output = cmJoin(this->GetDefinitions(cacheonly), ";");
+ output = cmJoin(this->GetState()->GetCacheEntryKeys(), ";");
return output.c_str();
}
- else if (prop == "MACROS")
+ else if (prop == "VARIABLES")
{
- this->GetListOfMacros(output);
+ output = cmJoin(this->GetDefinitions(), ";");
return output.c_str();
}
- else if (prop == "DEFINITIONS")
+ else if (prop == "MACROS")
{
- switch(this->GetPolicyStatus(cmPolicies::CMP0059))
- {
- case cmPolicies::WARN:
- this->IssueMessage(cmake::AUTHOR_WARNING, cmPolicies::
- GetPolicyWarning(cmPolicies::CMP0059));
- case cmPolicies::OLD:
- output += this->DefineFlagsOrig;
- return output.c_str();
- case cmPolicies::NEW:
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::REQUIRED_IF_USED:
- break;
- }
+ this->GetListOfMacros(output);
+ return output.c_str();
}
else if (prop == "LINK_DIRECTORIES")
{
@@ -4134,15 +4219,13 @@ const char *cmMakefile::GetProperty(const std::string& prop,
return output.c_str();
}
- bool chain = false;
- const char *retVal =
- this->Properties.GetPropertyValue(prop, scope, chain);
- if (chain)
+ const char *retVal = this->Properties.GetPropertyValue(prop);
+ if (!retVal && chain)
{
if(this->LocalGenerator->GetParent())
{
return this->LocalGenerator->GetParent()->GetMakefile()->
- GetProperty(prop, scope);
+ GetProperty(prop, chain);
}
return this->GetState()->GetGlobalProperty(prop);
}
@@ -4155,33 +4238,6 @@ bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
return cmSystemTools::IsOn(this->GetProperty(prop));
}
-//----------------------------------------------------------------------------
-const char* cmMakefile::GetFeature(const std::string& feature,
- const std::string& config)
-{
- // TODO: Define accumulation policy for features (prepend, append, replace).
- // Currently we always replace.
- if(!config.empty())
- {
- std::string featureConfig = feature;
- featureConfig += "_";
- featureConfig += cmSystemTools::UpperCase(config);
- if(const char* value = this->GetProperty(featureConfig))
- {
- return value;
- }
- }
- if(const char* value = this->GetProperty(feature))
- {
- return value;
- }
- if(cmLocalGenerator* parent = this->LocalGenerator->GetParent())
- {
- return parent->GetMakefile()->GetFeature(feature, config);
- }
- return 0;
-}
-
cmTarget* cmMakefile::FindTarget(const std::string& name,
bool excludeAliases) const
{
@@ -4597,6 +4653,16 @@ void cmMakefile::StoreMatches(cmsys::RegularExpression& re)
this->MarkVariableAsUsed(nMatchesVariable);
}
+cmState::Snapshot cmMakefile::GetStateSnapshot() const
+{
+ return this->StateSnapshot;
+}
+
+const char* cmMakefile::GetDefineFlagsCMP0059() const
+{
+ return this->DefineFlagsOrig.c_str();
+}
+
//----------------------------------------------------------------------------
cmPolicies::PolicyStatus
cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
@@ -5358,3 +5424,41 @@ AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const
}
return true;
}
+
+
+cmMakefile::FunctionPushPop::FunctionPushPop(cmMakefile* mf,
+ cmPolicies::PolicyMap const& pm)
+ : Makefile(mf), ReportError(true)
+{
+ this->Makefile->PushFunctionScope(pm);
+}
+
+cmMakefile::FunctionPushPop::~FunctionPushPop()
+{
+ this->Makefile->PopFunctionScope(this->ReportError);
+}
+
+
+cmMakefile::MacroPushPop::MacroPushPop(cmMakefile* mf,
+ const cmPolicies::PolicyMap& pm)
+ : Makefile(mf), ReportError(true)
+{
+ this->Makefile->PushMacroScope(pm);
+}
+
+cmMakefile::MacroPushPop::~MacroPushPop()
+{
+ this->Makefile->PopMacroScope(this->ReportError);
+}
+
+cmMakefileCall::cmMakefileCall(cmMakefile* mf, const cmListFileContext& lfc,
+ cmExecutionStatus& status): Makefile(mf)
+{
+ cmMakefile::CallStackEntry entry = {&lfc, &status};
+ this->Makefile->CallStack.push_back(entry);
+}
+
+cmMakefileCall::~cmMakefileCall()
+{
+ this->Makefile->CallStack.pop_back();
+}