summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx201
1 files changed, 127 insertions, 74 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 0bd1624..53fd56f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -102,7 +102,6 @@ cmMakefile::cmMakefile(): Internal(new Internals)
this->PreOrder = false;
this->GeneratingBuildSystem = false;
- this->NumLastMatches = 0;
this->SuppressWatches = false;
}
@@ -153,7 +152,6 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
this->ListFileStack = mf.ListFileStack;
this->OutputToSource = mf.OutputToSource;
- this->NumLastMatches = mf.NumLastMatches;
this->SuppressWatches = mf.SuppressWatches;
}
@@ -171,6 +169,9 @@ void cmMakefile::Initialize()
// Protect the directory-level policies.
this->PushPolicyBarrier();
+ // push empty loop block
+ this->PushLoopBlockBarrier();
+
// By default the check is not done. It is enabled by
// cmListFileCache in the top level if necessary.
this->CheckCMP0000 = false;
@@ -880,12 +881,14 @@ void cmMakefile::ConfigureFinalPass()
//----------------------------------------------------------------------------
void
cmMakefile::AddCustomCommandToTarget(const std::string& target,
+ const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
cmTarget::CustomCommandType type,
const char* comment,
const char* workingDir,
- bool escapeOldStyle) const
+ bool escapeOldStyle,
+ bool uses_terminal)
{
// Find the target to which to add the custom command.
cmTargets::iterator ti = this->Targets.find(target);
@@ -935,12 +938,24 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target,
this->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
+
+ // Always create the byproduct sources and mark them generated.
+ for(std::vector<std::string>::const_iterator o = byproducts.begin();
+ o != byproducts.end(); ++o)
+ {
+ if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
+ {
+ out->SetProperty("GENERATED", "1");
+ }
+ }
+
// Add the command to the appropriate build step for the target.
std::vector<std::string> no_output;
- cmCustomCommand cc(this, no_output, depends,
+ cmCustomCommand cc(this, no_output, byproducts, depends,
commandLines, comment, workingDir);
cc.SetEscapeOldStyle(escapeOldStyle);
cc.SetEscapeAllowMakeVars(true);
+ cc.SetUsesTerminal(uses_terminal);
switch(type)
{
case cmTarget::PRE_BUILD:
@@ -958,13 +973,15 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target,
//----------------------------------------------------------------------------
cmSourceFile*
cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
+ const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const std::string& main_dependency,
const cmCustomCommandLines& commandLines,
const char* comment,
const char* workingDir,
bool replace,
- bool escapeOldStyle)
+ bool escapeOldStyle,
+ bool uses_terminal)
{
// Make sure there is at least one output.
if(outputs.empty())
@@ -1055,6 +1072,14 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
out->SetProperty("GENERATED", "1");
}
}
+ for(std::vector<std::string>::const_iterator o = byproducts.begin();
+ o != byproducts.end(); ++o)
+ {
+ if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
+ {
+ out->SetProperty("GENERATED", "1");
+ }
+ }
// Attach the custom command to the file.
if(file)
@@ -1067,10 +1092,11 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
}
cmCustomCommand* cc =
- new cmCustomCommand(this, outputs, depends2, commandLines,
- comment, workingDir);
+ new cmCustomCommand(this, outputs, byproducts, depends2,
+ commandLines, comment, workingDir);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetEscapeAllowMakeVars(true);
+ cc->SetUsesTerminal(uses_terminal);
file->SetCustomCommand(cc);
this->UpdateOutputToSourceMap(outputs, file);
}
@@ -1119,13 +1145,17 @@ cmMakefile::AddCustomCommandToOutput(const std::string& output,
const char* comment,
const char* workingDir,
bool replace,
- bool escapeOldStyle)
+ bool escapeOldStyle,
+ bool uses_terminal)
{
std::vector<std::string> outputs;
outputs.push_back(output);
- return this->AddCustomCommandToOutput(outputs, depends, main_dependency,
+ std::vector<std::string> no_byproducts;
+ return this->AddCustomCommandToOutput(outputs, no_byproducts,
+ depends, main_dependency,
commandLines, comment, workingDir,
- replace, escapeOldStyle);
+ replace, escapeOldStyle,
+ uses_terminal);
}
//----------------------------------------------------------------------------
@@ -1144,7 +1174,9 @@ cmMakefile::AddCustomCommandOldStyle(const std::string& target,
// In the old-style signature if the source and target were the
// same then it added a post-build rule to the target. Preserve
// this behavior.
- this->AddCustomCommandToTarget(target, depends, commandLines,
+ std::vector<std::string> no_byproducts;
+ this->AddCustomCommandToTarget(target, no_byproducts,
+ depends, commandLines,
cmTarget::POST_BUILD, comment, 0);
return;
}
@@ -1242,7 +1274,25 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
const char* workingDirectory,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
- bool escapeOldStyle, const char* comment)
+ bool escapeOldStyle, const char* comment,
+ bool uses_terminal)
+{
+ std::vector<std::string> no_byproducts;
+ return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory,
+ no_byproducts, depends, commandLines,
+ escapeOldStyle, comment, uses_terminal);
+}
+
+//----------------------------------------------------------------------------
+cmTarget*
+cmMakefile::AddUtilityCommand(const std::string& utilityName,
+ bool excludeFromAll,
+ const char* workingDirectory,
+ const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends,
+ const cmCustomCommandLines& commandLines,
+ bool escapeOldStyle, const char* comment,
+ bool uses_terminal)
{
// Create a target instance for this utility.
cmTarget* target = this->AddNewTarget(cmTarget::UTILITY, utilityName);
@@ -1263,13 +1313,15 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
force += cmake::GetCMakeFilesDirectory();
force += "/";
force += utilityName;
+ std::vector<std::string> forced;
+ forced.push_back(force);
std::string no_main_dependency = "";
bool no_replace = false;
- this->AddCustomCommandToOutput(force, depends,
- no_main_dependency,
+ this->AddCustomCommandToOutput(forced, byproducts,
+ depends, no_main_dependency,
commandLines, comment,
workingDirectory, no_replace,
- escapeOldStyle);
+ escapeOldStyle, uses_terminal);
cmSourceFile* sf = target->AddSourceCMP0049(force);
// The output is not actually created so mark it symbolic.
@@ -1282,6 +1334,16 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
cmSystemTools::Error("Could not get source file entry for ",
force.c_str());
}
+
+ // Always create the byproduct sources and mark them generated.
+ for(std::vector<std::string>::const_iterator o = byproducts.begin();
+ o != byproducts.end(); ++o)
+ {
+ if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
+ {
+ out->SetProperty("GENERATED", "1");
+ }
+ }
}
return target;
}
@@ -1832,7 +1894,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
{
if(!cmSystemTools::IsOff(files[cc].c_str()))
{
- files[cc] = cmSystemTools::CollapseFullPath(files[cc].c_str());
+ files[cc] = cmSystemTools::CollapseFullPath(files[cc]);
}
if ( cc > 0 )
{
@@ -1937,11 +1999,11 @@ void cmMakefile::CheckForUnused(const char* reason,
bt.push_back(lfc);
}
if (this->CheckSystemVars ||
- cmSystemTools::IsSubDirectory(path.c_str(),
+ cmSystemTools::IsSubDirectory(path,
this->GetHomeDirectory()) ||
- (cmSystemTools::IsSubDirectory(path.c_str(),
+ (cmSystemTools::IsSubDirectory(path,
this->GetHomeOutputDirectory()) &&
- !cmSystemTools::IsSubDirectory(path.c_str(),
+ !cmSystemTools::IsSubDirectory(path,
cmake::GetCMakeFilesDirectory())))
{
cmOStringStream msg;
@@ -2878,7 +2940,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
bt.push_back(lfc);
msg << "uninitialized variable \'" << lookup << "\'";
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
- msg.str().c_str(), bt);
+ msg.str(), bt);
}
}
}
@@ -3293,6 +3355,38 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
}
//----------------------------------------------------------------------------
+void cmMakefile::PushLoopBlock()
+{
+ assert(!this->LoopBlockCounter.empty());
+ this->LoopBlockCounter.top()++;
+}
+
+void cmMakefile::PopLoopBlock()
+{
+ assert(!this->LoopBlockCounter.empty());
+ assert(this->LoopBlockCounter.top() > 0);
+ this->LoopBlockCounter.top()--;
+}
+
+void cmMakefile::PushLoopBlockBarrier()
+{
+ this->LoopBlockCounter.push(0);
+}
+
+void cmMakefile::PopLoopBlockBarrier()
+{
+ assert(!this->LoopBlockCounter.empty());
+ assert(this->LoopBlockCounter.top() == 0);
+ this->LoopBlockCounter.pop();
+}
+
+bool cmMakefile::IsLoopBlock() const
+{
+ assert(!this->LoopBlockCounter.empty());
+ return !this->LoopBlockCounter.empty() && this->LoopBlockCounter.top() > 0;
+}
+
+//----------------------------------------------------------------------------
bool cmMakefile::ExpandArguments(
std::vector<cmListFileArgument> const& inArgs,
std::vector<std::string>& outArgs) const
@@ -3556,7 +3650,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
{
this->Internal->IsSourceFileTryCompile = fast;
// does the binary directory exist ? If not create it...
- if (!cmSystemTools::FileIsDirectory(bindir.c_str()))
+ if (!cmSystemTools::FileIsDirectory(bindir))
{
cmSystemTools::MakeDirectory(bindir.c_str());
}
@@ -3564,7 +3658,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
// change to the tests directory and run cmake
// use the cmake object instead of calling cmake
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(bindir.c_str());
+ cmSystemTools::ChangeDirectory(bindir);
// make sure the same generator is used
// use this program as the cmake to be run, it should not
@@ -3579,7 +3673,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
cmSystemTools::Error(
"Internal CMake error, TryCompile bad GlobalGenerator");
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
this->Internal->IsSourceFileTryCompile = false;
return 1;
}
@@ -3653,7 +3747,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
cmSystemTools::Error(
"Internal CMake error, TryCompile configure of cmake failed");
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
this->Internal->IsSourceFileTryCompile = false;
return 1;
}
@@ -3663,7 +3757,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
cmSystemTools::Error(
"Internal CMake error, TryCompile generation of cmake failed");
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
this->Internal->IsSourceFileTryCompile = false;
return 1;
}
@@ -3677,7 +3771,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
output,
this);
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
this->Internal->IsSourceFileTryCompile = false;
return ret;
}
@@ -4036,7 +4130,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
{
cmSystemTools::SetPermissions(soutfile.c_str(), perm);
}
- cmSystemTools::RemoveFile(tempOutputFile.c_str());
+ cmSystemTools::RemoveFile(tempOutputFile);
}
return res;
}
@@ -4426,10 +4520,14 @@ void cmMakefile::PushScope()
this->Internal->VarStack.push(cmDefinitions(parent));
this->Internal->VarInitStack.push(init);
this->Internal->VarUsageStack.push(usage);
+
+ this->PushLoopBlockBarrier();
}
void cmMakefile::PopScope()
{
+ this->PopLoopBlockBarrier();
+
cmDefinitions* current = &this->Internal->VarStack.top();
std::set<std::string> init = this->Internal->VarInitStack.top();
std::set<std::string> usage = this->Internal->VarUsageStack.top();
@@ -4743,51 +4841,6 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const
return this->QtUiFilesWithOptions;
}
-static std::string matchVariables[] = {
- "CMAKE_MATCH_0",
- "CMAKE_MATCH_1",
- "CMAKE_MATCH_2",
- "CMAKE_MATCH_3",
- "CMAKE_MATCH_4",
- "CMAKE_MATCH_5",
- "CMAKE_MATCH_6",
- "CMAKE_MATCH_7",
- "CMAKE_MATCH_8",
- "CMAKE_MATCH_9"
-};
-
-//----------------------------------------------------------------------------
-void cmMakefile::ClearMatches()
-{
- for (unsigned int i=0; i<this->NumLastMatches; i++)
- {
- std::string const& var = matchVariables[i];
- std::string const& s = this->GetSafeDefinition(var);
- if(!s.empty())
- {
- this->AddDefinition(var, "");
- this->MarkVariableAsUsed(var);
- }
- }
- this->NumLastMatches = 0;
-}
-
-//----------------------------------------------------------------------------
-void cmMakefile::StoreMatches(cmsys::RegularExpression& re)
-{
- for (unsigned int i=0; i<10; i++)
- {
- std::string const& m = re.match(i);
- if(!m.empty())
- {
- std::string const& var = matchVariables[i];
- this->AddDefinition(var, m.c_str());
- this->MarkVariableAsUsed(var);
- this->NumLastMatches = i + 1;
- }
- }
-}
-
//----------------------------------------------------------------------------
cmPolicies::PolicyStatus
cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
@@ -5208,7 +5261,7 @@ HaveCFeatureAvailable(cmTarget const* target, const std::string& feature) const
cmOStringStream e;
e << "The C_STANDARD property on target \"" << target->GetName()
<< "\" contained an invalid value: \"" << existingCStandard << "\".";
- this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
@@ -5459,7 +5512,7 @@ AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const
cmOStringStream e;
e << "The C_STANDARD property on target \"" << target->GetName()
<< "\" contained an invalid value: \"" << existingCStandard << "\".";
- this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
}