diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 848cfd1a2..662f77d32 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -215,7 +215,8 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf) if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endfunction")) { std::vector 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/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 7793dc40f..c3e67d747 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -251,7 +251,8 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf) if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endmacro")) { std::vector 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 63dbe27fc..72aa74cb3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3313,11 +3313,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 const& inArgs, - std::vector& outArgs) const + std::vector& outArgs, const char* filename) const { + std::string efp = this->GetExecutionFilePath(); + if (!filename) + { + filename = efp.c_str(); + } std::vector::const_iterator i; std::string value; outArgs.reserve(inArgs.size()); @@ -3332,8 +3346,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. @@ -3352,8 +3365,13 @@ bool cmMakefile::ExpandArguments( //---------------------------------------------------------------------------- bool cmMakefile::ExpandArguments( std::vector const& inArgs, - std::vector& outArgs) const + std::vector& outArgs, const char* filename) const { + std::string efp = this->GetExecutionFilePath(); + if (!filename) + { + filename = efp.c_str(); + } std::vector::const_iterator i; std::string value; outArgs.reserve(inArgs.size()); @@ -3368,8 +3386,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 86bde0ca7..8930b6dff 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -662,10 +662,12 @@ public: * variable replacement and list expansion. */ bool ExpandArguments(std::vector const& inArgs, - std::vector& outArgs) const; + std::vector& outArgs, + const char* filename = 0) const; bool ExpandArguments(std::vector const& inArgs, - std::vector& outArgs) const; + std::vector& outArgs, + const char* filename = 0) const; /** * Get the instance @@ -840,6 +842,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);