summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/manual/cmake-buildsystem.7.rst2
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmCPluginAPI.cxx3
-rw-r--r--Source/cmForEachCommand.cxx22
-rw-r--r--Source/cmForEachCommand.h5
-rw-r--r--Source/cmFunctionCommand.cxx17
-rw-r--r--Source/cmListFileCache.cxx5
-rw-r--r--Source/cmListFileCache.h12
-rw-r--r--Source/cmMacroCommand.cxx13
-rw-r--r--Source/cmMakefile.cxx172
-rw-r--r--Source/cmMakefile.h32
-rw-r--r--Source/cmQtAutoGenerators.cxx25
-rw-r--r--Source/cmVariableWatchCommand.cxx12
-rw-r--r--Source/cmWhileCommand.cxx17
-rw-r--r--Source/cmWhileCommand.h5
-rw-r--r--Tests/QtAutogen/CMakeLists.txt27
-rw-r--r--Tests/QtAutogen/automoc_rerun/CMakeLists.txt27
-rw-r--r--Tests/QtAutogen/automoc_rerun/input.txt1
-rw-r--r--Tests/QtAutogen/automoc_rerun/res1.qrc5
-rw-r--r--Tests/QtAutogen/automoc_rerun/test1.cpp5
-rw-r--r--Tests/QtAutogen/automoc_rerun/test1.h.in18
-rw-r--r--Tests/QtAutogen/automoc_rerun/test1.h.in27
-rw-r--r--Tests/RunCMake/Syntax/FunctionUnmatched-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt6
-rw-r--r--Tests/RunCMake/Syntax/FunctionUnmatched.cmake2
-rw-r--r--Tests/RunCMake/Syntax/MacroUnmatched-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt6
-rw-r--r--Tests/RunCMake/Syntax/MacroUnmatched.cmake2
-rw-r--r--Tests/RunCMake/Syntax/RunCMakeTest.cmake2
29 files changed, 269 insertions, 175 deletions
diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst
index c456590..aefdb71 100644
--- a/Help/manual/cmake-buildsystem.7.rst
+++ b/Help/manual/cmake-buildsystem.7.rst
@@ -632,7 +632,7 @@ may be enabled, with an equivalent effect to:
.. code-block:: cmake
- set_property(TARGET tgt APPEND PROPERTY
+ set_property(TARGET tgt APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR}>
)
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 9d68172..98e75c7 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 20150621)
+set(CMake_VERSION_PATCH 20150623)
#set(CMake_VERSION_RC 1)
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 0d24ed5..591a2cd 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -426,8 +426,7 @@ int CCONV cmExecuteCommand(void *arg, const char *name,
{
// Assume all arguments are quoted.
lff.Arguments.push_back(
- cmListFileArgument(args[i], cmListFileArgument::Quoted,
- "[CMake-Plugin]", 0));
+ cmListFileArgument(args[i], cmListFileArgument::Quoted, 0));
}
cmExecutionStatus status;
return mf->ExecuteCommand(lff,status);
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 0dcda4d..e983bfb 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -13,6 +13,17 @@
#include <cmsys/auto_ptr.hxx>
+cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf):
+ Makefile(mf), Depth(0)
+{
+ this->Makefile->PushLoopBlock();
+}
+
+cmForEachFunctionBlocker::~cmForEachFunctionBlocker()
+{
+ this->Makefile->PopLoopBlock();
+}
+
bool cmForEachFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
cmExecutionStatus &inStatus)
@@ -27,8 +38,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
// if this is the endofreach for this statement
if (!this->Depth)
{
- cmMakefile::LoopBlockPop loopBlockPop(&mf);
-
// Remove the function blocker for this scope or bail.
cmsys::auto_ptr<cmFunctionBlocker>
fb(mf.RemoveFunctionBlocker(this, lff));
@@ -128,7 +137,7 @@ bool cmForEachCommand
}
// create a function blocker
- cmForEachFunctionBlocker *f = new cmForEachFunctionBlocker();
+ cmForEachFunctionBlocker *f = new cmForEachFunctionBlocker(this->Makefile);
if ( args.size() > 1 )
{
if ( args[1] == "RANGE" )
@@ -204,15 +213,14 @@ bool cmForEachCommand
}
this->Makefile->AddFunctionBlocker(f);
- this->Makefile->PushLoopBlock();
-
return true;
}
//----------------------------------------------------------------------------
bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
{
- cmsys::auto_ptr<cmForEachFunctionBlocker> f(new cmForEachFunctionBlocker());
+ cmsys::auto_ptr<cmForEachFunctionBlocker>
+ f(new cmForEachFunctionBlocker(this->Makefile));
f->Args.push_back(args[0]);
enum Doing { DoingNone, DoingLists, DoingItems };
@@ -250,7 +258,5 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr
- this->Makefile->PushLoopBlock();
-
return true;
}
diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h
index 9b7c85a..36e8808 100644
--- a/Source/cmForEachCommand.h
+++ b/Source/cmForEachCommand.h
@@ -19,8 +19,8 @@
class cmForEachFunctionBlocker : public cmFunctionBlocker
{
public:
- cmForEachFunctionBlocker() {this->Depth = 0;}
- virtual ~cmForEachFunctionBlocker() {}
+ cmForEachFunctionBlocker(cmMakefile* mf);
+ ~cmForEachFunctionBlocker();
virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
cmMakefile &mf,
cmExecutionStatus &);
@@ -29,6 +29,7 @@ public:
std::vector<std::string> Args;
std::vector<cmListFileFunction> Functions;
private:
+ cmMakefile* Makefile;
int Depth;
};
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index dc6d2d2..b3576c3 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -43,6 +43,7 @@ public:
newC->Args = this->Args;
newC->Functions = this->Functions;
newC->Policies = this->Policies;
+ newC->FilePath = this->FilePath;
return newC;
}
@@ -71,6 +72,7 @@ public:
std::vector<std::string> Args;
std::vector<cmListFileFunction> Functions;
cmPolicies::PolicyMap Policies;
+ std::string FilePath;
};
bool cmFunctionHelperCommand::InvokeInitialPass
@@ -171,19 +173,9 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
cmFunctionHelperCommand *f = new cmFunctionHelperCommand();
f->Args = this->Args;
f->Functions = this->Functions;
+ f->FilePath = this->GetStartingContext().FilePath;
mf.RecordPolicies(f->Policies);
- // Set the FilePath on the arguments to match the function since it is
- // not stored and the original values may be freed
- for (unsigned int i = 0; i < f->Functions.size(); ++i)
- {
- for (unsigned int j = 0; j < f->Functions[i].Arguments.size(); ++j)
- {
- f->Functions[i].Arguments[j].FilePath =
- f->Functions[i].FilePath.c_str();
- }
- }
-
std::string newName = "_" + this->Args[0];
mf.GetState()->RenameCommand(this->Args[0], newName);
mf.GetState()->AddCommand(f);
@@ -212,7 +204,8 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf)
if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endfunction"))
{
std::vector<std::string> expandedArguments;
- mf.ExpandArguments(lff.Arguments, expandedArguments);
+ mf.ExpandArguments(lff.Arguments, expandedArguments,
+ this->GetStartingContext().FilePath.c_str());
// if the endfunction has arguments then make sure
// they match the ones in the opening function command
if ((expandedArguments.empty() ||
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index ca58314..006ca4c 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -234,8 +234,7 @@ bool cmListFile::ParseFile(const char* filename,
{
cmListFileFunction project;
project.Name = "PROJECT";
- cmListFileArgument prj("Project", cmListFileArgument::Unquoted,
- filename, 0);
+ cmListFileArgument prj("Project", cmListFileArgument::Unquoted, 0);
project.Arguments.push_back(prj);
this->Functions.insert(this->Functions.begin(),project);
}
@@ -375,7 +374,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
cmListFileArgument::Delimiter delim)
{
- cmListFileArgument a(token->text, delim, this->FileName, token->line);
+ cmListFileArgument a(token->text, delim, token->line);
this->Function.Arguments.push_back(a);
if(this->Separation == SeparationOkay)
{
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 4002d94..f5859ec 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -33,12 +33,11 @@ struct cmListFileArgument
Quoted,
Bracket
};
- cmListFileArgument(): Value(), Delim(Unquoted), FilePath(0), Line(0) {}
- cmListFileArgument(const cmListFileArgument& r):
- Value(r.Value), Delim(r.Delim), FilePath(r.FilePath), Line(r.Line) {}
- cmListFileArgument(const std::string& v, Delimiter d, const char* file,
- long line): Value(v), Delim(d),
- FilePath(file), Line(line) {}
+ cmListFileArgument(): Value(), Delim(Unquoted), Line(0) {}
+ cmListFileArgument(const cmListFileArgument& r)
+ : Value(r.Value), Delim(r.Delim), Line(r.Line) {}
+ cmListFileArgument(const std::string& v, Delimiter d, long line)
+ : Value(v), Delim(d), Line(line) {}
bool operator == (const cmListFileArgument& r) const
{
return (this->Value == r.Value) && (this->Delim == r.Delim);
@@ -49,7 +48,6 @@ struct cmListFileArgument
}
std::string Value;
Delimiter Delim;
- const char* FilePath;
long Line;
};
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 028ab62..0b945b2 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -122,10 +122,6 @@ bool cmMacroHelperCommand::InvokeInitialPass
sprintf(argvName,"${ARGV%i}",j);
argVs.push_back(argvName);
}
- if(!this->Functions.empty())
- {
- this->FilePath = this->Functions[0].FilePath;
- }
// Invoke all the functions that were collected in the block.
cmListFileFunction newLFF;
// for each function
@@ -143,10 +139,6 @@ bool cmMacroHelperCommand::InvokeInitialPass
this->Functions[c].Arguments.begin();
k != this->Functions[c].Arguments.end(); ++k)
{
- // Set the FilePath on the arguments to match the function since it is
- // not stored and the original values may be freed
- k->FilePath = this->FilePath.c_str();
-
cmListFileArgument arg;
arg.Value = k->Value;
if(k->Delim != cmListFileArgument::Bracket)
@@ -177,7 +169,6 @@ bool cmMacroHelperCommand::InvokeInitialPass
}
}
arg.Delim = k->Delim;
- arg.FilePath = k->FilePath;
arg.Line = k->Line;
newLFF.Arguments.push_back(arg);
}
@@ -225,6 +216,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
cmMacroHelperCommand *f = new cmMacroHelperCommand();
f->Args = this->Args;
f->Functions = this->Functions;
+ f->FilePath = this->GetStartingContext().FilePath;
mf.RecordPolicies(f->Policies);
std::string newName = "_" + this->Args[0];
mf.GetState()->RenameCommand(this->Args[0], newName);
@@ -254,7 +246,8 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf)
if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endmacro"))
{
std::vector<std::string> expandedArguments;
- mf.ExpandArguments(lff.Arguments, expandedArguments);
+ mf.ExpandArguments(lff.Arguments, expandedArguments,
+ this->GetStartingContext().FilePath.c_str());
// if the endmacro has arguments make sure they
// match the arguments of the macro
if ((expandedArguments.empty() ||
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 64d8638..a3ba134 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -308,7 +308,7 @@ cmListFileContext cmMakefile::GetExecutionContext() const
void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
{
std::ostringstream msg;
- msg << lff.FilePath << "(" << lff.Line << "): ";
+ msg << this->GetExecutionFilePath() << "(" << lff.Line << "): ";
msg << lff.Name << "(";
for(std::vector<cmListFileArgument>::const_iterator i =
lff.Arguments.begin(); i != lff.Arguments.end(); ++i)
@@ -409,12 +409,12 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
class cmMakefile::IncludeScope
{
public:
- IncludeScope(cmMakefile* mf, const char* fname, bool noPolicyScope);
+ IncludeScope(cmMakefile* mf, std::string const& filenametoread,
+ bool noPolicyScope);
~IncludeScope();
void Quiet() { this->ReportError = false; }
private:
cmMakefile* Makefile;
- const char* File;
bool NoPolicyScope;
bool CheckCMP0011;
bool ReportError;
@@ -422,9 +422,10 @@ private:
};
//----------------------------------------------------------------------------
-cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, const char* fname,
+cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
+ std::string const& filenametoread,
bool noPolicyScope):
- Makefile(mf), File(fname), NoPolicyScope(noPolicyScope),
+ Makefile(mf), NoPolicyScope(noPolicyScope),
CheckCMP0011(false), ReportError(true)
{
if(!this->NoPolicyScope)
@@ -458,6 +459,7 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, const char* fname,
// The included file cannot pop our policy scope.
this->Makefile->PushPolicyBarrier();
+ this->Makefile->ListFileStack.push_back(filenametoread);
}
//----------------------------------------------------------------------------
@@ -487,6 +489,7 @@ cmMakefile::IncludeScope::~IncludeScope()
this->EnforceCMP0011();
}
}
+ this->Makefile->ListFileStack.pop_back();
}
//----------------------------------------------------------------------------
@@ -501,7 +504,8 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
{
std::ostringstream w;
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0011) << "\n"
- << "The included script\n " << this->File << "\n"
+ << "The included script\n "
+ << this->Makefile->ListFileStack.back() << "\n"
<< "affects policy settings. "
<< "CMake is implying the NO_POLICY_SCOPE option for compatibility, "
<< "so the effects are applied to the including context.";
@@ -513,7 +517,8 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
{
std::ostringstream e;
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0011) << "\n"
- << "The included script\n " << this->File << "\n"
+ << "The included script\n "
+ << this->Makefile->ListFileStack.back() << "\n"
<< "affects policy settings, so it requires this policy to be set.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}
@@ -527,39 +532,76 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
}
}
-bool cmMakefile::ProcessBuildsystemFile(const char* listfile)
+bool cmMakefile::ProcessBuildsystemFile(const char* filename)
{
- this->AddDefinition("CMAKE_PARENT_LIST_FILE", listfile);
+ this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename);
std::string curSrc = this->GetCurrentSourceDirectory();
- bool result = this->ReadListFile(listfile, true,
- curSrc == this->GetHomeDirectory());
+
+ this->ListFileStack.push_back(filename);
+
+ cmListFile listFile;
+ if (!listFile.ParseFile(filename, curSrc == this->GetHomeDirectory(), this))
+ {
+ return false;
+ }
+
+ this->PushPolicyBarrier();
+ this->ReadListFile(listFile, filename);
+ this->PopPolicyBarrier(!cmSystemTools::GetFatalErrorOccured());
this->EnforceDirectoryLevelRules();
- return result;
+ return true;
}
-bool cmMakefile::ReadDependentFile(const char* listfile, bool noPolicyScope)
+bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
{
this->AddDefinition("CMAKE_PARENT_LIST_FILE",
this->GetDefinition("CMAKE_CURRENT_LIST_FILE"));
- bool result = this->ReadListFile(listfile, noPolicyScope, false);
- this->ListFileStack.pop_back();
- return result;
+ std::string filenametoread =
+ cmSystemTools::CollapseFullPath(filename,
+ this->GetCurrentSourceDirectory());
+
+ IncludeScope incScope(this, filenametoread, noPolicyScope);
+
+ cmListFile listFile;
+ if (!listFile.ParseFile(filenametoread.c_str(), false, this))
+ {
+ incScope.Quiet();
+ return false;
+ }
+ this->ReadListFile(listFile, filenametoread);
+ if(cmSystemTools::GetFatalErrorOccured())
+ {
+ incScope.Quiet();
+ }
+ return true;
}
-bool cmMakefile::ReadListFile(const char* listfile)
+bool cmMakefile::ReadListFile(const char* filename)
{
- bool result = this->ReadListFile(listfile, true, false);
+ std::string filenametoread =
+ cmSystemTools::CollapseFullPath(filename,
+ this->GetCurrentSourceDirectory());
+
+ this->ListFileStack.push_back(filenametoread);
+
+ cmListFile listFile;
+ if (!listFile.ParseFile(filenametoread.c_str(), false, this))
+ {
+ return false;
+ }
+
+ this->PushPolicyBarrier();
+ this->ReadListFile(listFile, filenametoread);
+ this->PopPolicyBarrier(!cmSystemTools::GetFatalErrorOccured());
this->ListFileStack.pop_back();
- return result;
+ return true;
}
-bool cmMakefile::ReadListFile(const char* listfile,
- bool noPolicyScope,
- bool requireProjectCommand)
+void cmMakefile::ReadListFile(cmListFile const& listFile,
+ std::string const& filenametoread)
{
- std::string filenametoread =
- cmSystemTools::CollapseFullPath(listfile,
- this->GetCurrentSourceDirectory());
+ // add this list file to the list of dependencies
+ this->ListFiles.push_back(filenametoread);
std::string currentParentFile
= this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE");
@@ -574,55 +616,19 @@ bool cmMakefile::ReadListFile(const char* listfile,
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
- this->ListFileStack.push_back(filenametoread);
-
- bool res = this->ReadListFileInternal(filenametoread.c_str(),
- noPolicyScope, requireProjectCommand);
-
- this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
- this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str());
- this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
- cmSystemTools::GetFilenamePath(currentFile).c_str());
- this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
- this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
- this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
-
- if (res)
- {
- this->CheckForUnusedVariables();
- }
-
- return res;
-}
-
-bool cmMakefile::ReadListFileInternal(const char* filenametoread,
- bool noPolicyScope,
- bool requireProjectCommand)
-{
- cmListFile cacheFile;
- if( !cacheFile.ParseFile(filenametoread, requireProjectCommand, this) )
- {
- return false;
- }
- // add this list file to the list of dependencies
- this->ListFiles.push_back( filenametoread);
-
// Enforce balanced blocks (if/endif, function/endfunction, etc.).
- {
LexicalPushPop lexScope(this);
- IncludeScope incScope(this, filenametoread, noPolicyScope);
// Run the parsed commands.
- const size_t numberFunctions = cacheFile.Functions.size();
+ const size_t numberFunctions = listFile.Functions.size();
for(size_t i =0; i < numberFunctions; ++i)
{
cmExecutionStatus status;
- this->ExecuteCommand(cacheFile.Functions[i],status);
+ this->ExecuteCommand(listFile.Functions[i],status);
if(cmSystemTools::GetFatalErrorOccured())
{
// Exit early due to error.
lexScope.Quiet();
- incScope.Quiet();
break;
}
if(status.GetReturnInvoked())
@@ -631,9 +637,15 @@ bool cmMakefile::ReadListFileInternal(const char* filenametoread,
break;
}
}
- }
+ this->CheckForUnusedVariables();
- return true;
+ this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
+ this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str());
+ this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
+ cmSystemTools::GetFilenamePath(currentFile).c_str());
+ this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
+ this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
+ this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
}
//----------------------------------------------------------------------------
@@ -3267,7 +3279,6 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
this->FunctionBlockerBarriers.back();
while(this->FunctionBlockers.size() > barrier)
{
- cmMakefile::LoopBlockPop loopBlockPop(this);
cmsys::auto_ptr<cmFunctionBlocker> fb(this->FunctionBlockers.back());
this->FunctionBlockers.pop_back();
if(reportError)
@@ -3319,11 +3330,25 @@ bool cmMakefile::IsLoopBlock() const
return !this->LoopBlockCounter.empty() && this->LoopBlockCounter.top() > 0;
}
+std::string cmMakefile::GetExecutionFilePath() const
+{
+ if (this->CallStack.empty())
+ {
+ return std::string();
+ }
+ return this->CallStack.back().Context->FilePath;
+}
+
//----------------------------------------------------------------------------
bool cmMakefile::ExpandArguments(
std::vector<cmListFileArgument> const& inArgs,
- std::vector<std::string>& outArgs) const
+ std::vector<std::string>& outArgs, const char* filename) const
{
+ std::string efp = this->GetExecutionFilePath();
+ if (!filename)
+ {
+ filename = efp.c_str();
+ }
std::vector<cmListFileArgument>::const_iterator i;
std::string value;
outArgs.reserve(inArgs.size());
@@ -3338,8 +3363,7 @@ bool cmMakefile::ExpandArguments(
// Expand the variables in the argument.
value = i->Value;
this->ExpandVariablesInString(value, false, false, false,
- i->FilePath, i->Line,
- false, false);
+ filename, i->Line, false, false);
// If the argument is quoted, it should be one argument.
// Otherwise, it may be a list of arguments.
@@ -3358,8 +3382,13 @@ bool cmMakefile::ExpandArguments(
//----------------------------------------------------------------------------
bool cmMakefile::ExpandArguments(
std::vector<cmListFileArgument> const& inArgs,
- std::vector<cmExpandedCommandArgument>& outArgs) const
+ std::vector<cmExpandedCommandArgument>& outArgs, const char* filename) const
{
+ std::string efp = this->GetExecutionFilePath();
+ if (!filename)
+ {
+ filename = efp.c_str();
+ }
std::vector<cmListFileArgument>::const_iterator i;
std::string value;
outArgs.reserve(inArgs.size());
@@ -3374,8 +3403,7 @@ bool cmMakefile::ExpandArguments(
// Expand the variables in the argument.
value = i->Value;
this->ExpandVariablesInString(value, false, false, false,
- i->FilePath, i->Line,
- false, false);
+ filename, i->Line, false, false);
// If the argument is quoted, it should be one argument.
// Otherwise, it may be a list of arguments.
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 44bd8c6..85f117b 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -79,11 +79,11 @@ public:
*/
~cmMakefile();
- bool ReadListFile(const char* listfile);
+ bool ReadListFile(const char* filename);
- bool ReadDependentFile(const char* listfile, bool noPolicyScope = true);
+ bool ReadDependentFile(const char* filename, bool noPolicyScope = true);
- bool ProcessBuildsystemFile(const char* listfile);
+ bool ProcessBuildsystemFile(const char* filename);
/**
* Add a function blocker to this makefile
@@ -113,15 +113,6 @@ public:
};
friend class LexicalPushPop;
- class LoopBlockPop
- {
- public:
- LoopBlockPop(cmMakefile* mf) { this->Makefile = mf; }
- ~LoopBlockPop() { this->Makefile->PopLoopBlock(); }
- private:
- cmMakefile* Makefile;
- };
-
/**
* Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process.
@@ -665,10 +656,12 @@ public:
* variable replacement and list expansion.
*/
bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
- std::vector<std::string>& outArgs) const;
+ std::vector<std::string>& outArgs,
+ const char* filename = 0) const;
bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
- std::vector<cmExpandedCommandArgument>& outArgs) const;
+ std::vector<cmExpandedCommandArgument>& outArgs,
+ const char* filename = 0) const;
/**
* Get the instance
@@ -843,6 +836,8 @@ public:
const char* GetDefineFlagsCMP0059() const;
+ std::string GetExecutionFilePath() const;
+
protected:
// add link libraries and directories to the target
void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
@@ -917,13 +912,8 @@ private:
cmState::Snapshot StateSnapshot;
- bool ReadListFile(const char* listfile,
- bool noPolicyScope,
- bool requireProjectCommand);
-
- bool ReadListFileInternal(const char* filenametoread,
- bool noPolicyScope,
- bool requireProjectCommand);
+ void ReadListFile(cmListFile const& listFile,
+ const std::string& filenametoread);
bool ParseDefineFlag(std::string const& definition, bool remove);
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index b03e45a..32b9566 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -439,6 +439,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
this->ListQt4RccInputs(sf, depends);
}
#if defined(_WIN32) && !defined(__CYGWIN__)
+ // Cannot use PRE_BUILD because the resource files themselves
+ // may not be sources within the target so VS may not know the
+ // target needs to re-build at all.
usePRE_BUILD = false;
#endif
}
@@ -465,31 +468,11 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
else
#endif
{
- cmTarget* autogenTarget = 0;
- if (!rcc_output.empty() && !isNinja)
- {
- std::vector<std::string> no_byproducts;
- makefile->AddCustomCommandToOutput(rcc_output, no_byproducts,
- depends, "",
- commandLines, 0,
- workingDirectory.c_str(),
- false, false);
-
- cmCustomCommandLines no_commands;
- autogenTarget = makefile->AddUtilityCommand(
- autogenTargetName, true,
- workingDirectory.c_str(), rcc_output,
- no_commands, false, autogenComment.c_str());
-
- }
- else
- {
- autogenTarget = makefile->AddUtilityCommand(
+ cmTarget* autogenTarget = makefile->AddUtilityCommand(
autogenTargetName, true,
workingDirectory.c_str(),
/*byproducts=*/rcc_output, depends,
commandLines, false, autogenComment.c_str());
- }
// Set target folder
const char* autogenFolder = makefile->GetState()
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 09cef5e..6521c04 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -49,21 +49,21 @@ static void cmVariableWatchCommandVariableAccessed(
newLFF.Arguments.clear();
newLFF.Arguments.push_back(
cmListFileArgument(variable, cmListFileArgument::Quoted,
- "unknown", 9999));
+ 9999));
newLFF.Arguments.push_back(
cmListFileArgument(accessString, cmListFileArgument::Quoted,
- "unknown", 9999));
+ 9999));
newLFF.Arguments.push_back(
cmListFileArgument(newValue?newValue:"", cmListFileArgument::Quoted,
- "unknown", 9999));
+ 9999));
newLFF.Arguments.push_back(
cmListFileArgument(currentListFile, cmListFileArgument::Quoted,
- "unknown", 9999));
+ 9999));
newLFF.Arguments.push_back(
cmListFileArgument(stack, cmListFileArgument::Quoted,
- "unknown", 9999));
+ 9999));
newLFF.Name = data->Command;
- newLFF.FilePath = "Some weird path";
+ newLFF.FilePath = "unknown";
newLFF.Line = 9999;
cmExecutionStatus status;
if(!makefile->ExecuteCommand(newLFF,status))
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 5170ead..012c580 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -12,6 +12,17 @@
#include "cmWhileCommand.h"
#include "cmConditionEvaluator.h"
+cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf):
+ Makefile(mf), Depth(0)
+{
+ this->Makefile->PushLoopBlock();
+}
+
+cmWhileFunctionBlocker::~cmWhileFunctionBlocker()
+{
+ this->Makefile->PopLoopBlock();
+}
+
bool cmWhileFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
cmExecutionStatus &inStatus)
@@ -27,8 +38,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
// if this is the endwhile for this while loop then execute
if (!this->Depth)
{
- cmMakefile::LoopBlockPop loopBlockPop(&mf);
-
// Remove the function blocker for this scope or bail.
cmsys::auto_ptr<cmFunctionBlocker>
fb(mf.RemoveFunctionBlocker(this, lff));
@@ -140,12 +149,10 @@ bool cmWhileCommand
}
// create a function blocker
- cmWhileFunctionBlocker *f = new cmWhileFunctionBlocker();
+ cmWhileFunctionBlocker *f = new cmWhileFunctionBlocker(this->Makefile);
f->Args = args;
this->Makefile->AddFunctionBlocker(f);
- this->Makefile->PushLoopBlock();
-
return true;
}
diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h
index 9fafffc..85a0bd3 100644
--- a/Source/cmWhileCommand.h
+++ b/Source/cmWhileCommand.h
@@ -19,8 +19,8 @@
class cmWhileFunctionBlocker : public cmFunctionBlocker
{
public:
- cmWhileFunctionBlocker() {this->Depth=0;}
- virtual ~cmWhileFunctionBlocker() {}
+ cmWhileFunctionBlocker(cmMakefile* mf);
+ ~cmWhileFunctionBlocker();
virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
cmMakefile &mf,
cmExecutionStatus &);
@@ -29,6 +29,7 @@ public:
std::vector<cmListFileArgument> Args;
std::vector<cmListFileFunction> Functions;
private:
+ cmMakefile* Makefile;
int Depth;
};
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 60b44fd..ebcfc0f 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -34,8 +34,8 @@ else()
include_directories(${Qt5Widgets_INCLUDE_DIRS})
set(QT_LIBRARIES Qt5::Widgets)
- if(Qt5_POSITION_INDEPENDENT_CODE)
- set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+ if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
+ add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC})
endif()
macro(qtx_wrap_cpp)
@@ -167,3 +167,26 @@ file(TIMESTAMP "${qrc_file1}" file1_step1 "${timeformat}")
if (NOT file1_step1 GREATER file1_before)
message(SEND_ERROR "file1 (${qrc_file1}) should have changed in the first step!")
endif()
+
+#-----------------------------------------------------------------------------
+try_compile(MOC_RERUN
+ "${CMAKE_CURRENT_BINARY_DIR}/automoc_rerun"
+ "${CMAKE_CURRENT_SOURCE_DIR}/automoc_rerun"
+ automoc_rerun
+ CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
+ OUTPUT_VARIABLE output
+)
+if (NOT MOC_RERUN)
+ message(SEND_ERROR "Initial build of automoc_rerun failed. Output: ${output}")
+endif()
+
+configure_file(automoc_rerun/test1.h.in2 automoc_rerun/test1.h COPYONLY)
+
+execute_process(COMMAND "${CMAKE_COMMAND}" --build .
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/automoc_rerun"
+ RESULT_VARIABLE automoc_rerun_result
+ )
+if (automoc_rerun_result)
+ message(SEND_ERROR "Second build of automoc_rerun failed.")
+endif()
diff --git a/Tests/QtAutogen/automoc_rerun/CMakeLists.txt b/Tests/QtAutogen/automoc_rerun/CMakeLists.txt
new file mode 100644
index 0000000..17bc332
--- /dev/null
+++ b/Tests/QtAutogen/automoc_rerun/CMakeLists.txt
@@ -0,0 +1,27 @@
+cmake_minimum_required(VERSION 3.1)
+project(automoc_rerun CXX)
+
+if (QT_TEST_VERSION STREQUAL 4)
+ find_package(Qt4 REQUIRED)
+ set(QT_CORE_TARGET Qt4::QtCore)
+else()
+ if (NOT QT_TEST_VERSION STREQUAL 5)
+ message(SEND_ERROR "Invalid Qt version specified.")
+ endif()
+
+ find_package(Qt5Core REQUIRED)
+ set(QT_CORE_TARGET Qt5::Core)
+endif()
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+configure_file(test1.h.in1 test1.h COPYONLY)
+
+add_executable(test1
+ ${CMAKE_CURRENT_BINARY_DIR}/test1.h
+ test1.cpp
+ res1.qrc
+ )
+target_include_directories(test1 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_link_libraries(test1 ${QT_CORE_TARGET})
diff --git a/Tests/QtAutogen/automoc_rerun/input.txt b/Tests/QtAutogen/automoc_rerun/input.txt
new file mode 100644
index 0000000..da62762
--- /dev/null
+++ b/Tests/QtAutogen/automoc_rerun/input.txt
@@ -0,0 +1 @@
+Res1 input.
diff --git a/Tests/QtAutogen/automoc_rerun/res1.qrc b/Tests/QtAutogen/automoc_rerun/res1.qrc
new file mode 100644
index 0000000..fb804b5
--- /dev/null
+++ b/Tests/QtAutogen/automoc_rerun/res1.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>input.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/automoc_rerun/test1.cpp b/Tests/QtAutogen/automoc_rerun/test1.cpp
new file mode 100644
index 0000000..4316a91
--- /dev/null
+++ b/Tests/QtAutogen/automoc_rerun/test1.cpp
@@ -0,0 +1,5 @@
+#include "test1.h"
+int main()
+{
+ return 0;
+}
diff --git a/Tests/QtAutogen/automoc_rerun/test1.h.in1 b/Tests/QtAutogen/automoc_rerun/test1.h.in1
new file mode 100644
index 0000000..fee2c09
--- /dev/null
+++ b/Tests/QtAutogen/automoc_rerun/test1.h.in1
@@ -0,0 +1,8 @@
+#include <QObject>
+class test1 : public QObject
+{
+ Q_OBJECT
+ public slots:
+ void onTst1() {}
+ void onTst2() {}
+};
diff --git a/Tests/QtAutogen/automoc_rerun/test1.h.in2 b/Tests/QtAutogen/automoc_rerun/test1.h.in2
new file mode 100644
index 0000000..6531d10
--- /dev/null
+++ b/Tests/QtAutogen/automoc_rerun/test1.h.in2
@@ -0,0 +1,7 @@
+#include <QObject>
+class test1 : public QObject
+{
+ Q_OBJECT
+ public slots:
+ void onTst1() {}
+};
diff --git a/Tests/RunCMake/Syntax/FunctionUnmatched-result.txt b/Tests/RunCMake/Syntax/FunctionUnmatched-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/FunctionUnmatched-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt b/Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt
new file mode 100644
index 0000000..776a8f2
--- /dev/null
+++ b/Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at CMakeLists.txt:[0-9]+ \(include\):
+ A logical block opening on the line
+
+ .*/Tests/RunCMake/Syntax/FunctionUnmatched.cmake:[0-9]+ \(function\)
+
+ is not closed.$
diff --git a/Tests/RunCMake/Syntax/FunctionUnmatched.cmake b/Tests/RunCMake/Syntax/FunctionUnmatched.cmake
new file mode 100644
index 0000000..515b6bf
--- /dev/null
+++ b/Tests/RunCMake/Syntax/FunctionUnmatched.cmake
@@ -0,0 +1,2 @@
+function(f)
+#endfunction() # missing
diff --git a/Tests/RunCMake/Syntax/MacroUnmatched-result.txt b/Tests/RunCMake/Syntax/MacroUnmatched-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/MacroUnmatched-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt b/Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt
new file mode 100644
index 0000000..1699c43
--- /dev/null
+++ b/Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at CMakeLists.txt:[0-9]+ \(include\):
+ A logical block opening on the line
+
+ .*/Tests/RunCMake/Syntax/MacroUnmatched.cmake:[0-9]+ \(macro\)
+
+ is not closed.$
diff --git a/Tests/RunCMake/Syntax/MacroUnmatched.cmake b/Tests/RunCMake/Syntax/MacroUnmatched.cmake
new file mode 100644
index 0000000..302d96e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/MacroUnmatched.cmake
@@ -0,0 +1,2 @@
+macro(m)
+#endmacro() # missing
diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
index c431280..fd012b9 100644
--- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
@@ -110,5 +110,7 @@ run_cmake(CMP0053-NameWithEscapedSpacesQuoted)
run_cmake(CMP0053-NameWithEscapedTabsQuoted)
# Function and macro tests.
+run_cmake(FunctionUnmatched)
run_cmake(FunctionUnmatchedForeach)
+run_cmake(MacroUnmatched)
run_cmake(MacroUnmatchedForeach)