diff options
author | Brad King <brad.king@kitware.com> | 2004-08-04 14:45:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2004-08-04 14:45:11 (GMT) |
commit | b6da1d127196d82c58a3780432e9466b459d8543 (patch) | |
tree | 17a8359a57d7c1de7434c9f836d8e2eace470ca3 /Source/cmMakefile.cxx | |
parent | 743eed068cbd81747cac0184e7c4a43ce8aab8c3 (diff) | |
download | CMake-b6da1d127196d82c58a3780432e9466b459d8543.zip CMake-b6da1d127196d82c58a3780432e9466b459d8543.tar.gz CMake-b6da1d127196d82c58a3780432e9466b459d8543.tar.bz2 |
ENH: Added support for special variables CMAKE_CURRENT_LIST_FILE and CMAKE_CURRENT_LIST_LINE that evaluate to the file name and line number in which they appear. This implements the feature request from bug 1012.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f6b7225..4df29b1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1423,7 +1423,9 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source) const const char *cmMakefile::ExpandVariablesInString(std::string& source, bool escapeQuotes, - bool atOnly) const + bool atOnly, + const char* filename = 0, + long line = -1) const { // This method replaces ${VAR} and @VAR@ where VAR is looked up // with GetDefinition(), if not found in the map, nothing is expanded. @@ -1542,6 +1544,18 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source, } found = true; } + else if(filename && (var == "CMAKE_CURRENT_LIST_FILE")) + { + result += filename; + found = true; + } + else if(line >= 0 && (var == "CMAKE_CURRENT_LIST_LINE")) + { + cmOStringStream ostr; + ostr << line; + result += ostr.str(); + found = true; + } } // if found add to result, if not, then it gets blanked if (!found) @@ -1696,8 +1710,8 @@ void cmMakefile::ExpandArguments( { // Expand the variables in the argument. value = i->Value; - this->ExpandVariablesInString(value); - + this->ExpandVariablesInString(value, false, false, i->FilePath, i->Line); + // If the argument is quoted, it should be one argument. // Otherwise, it may be a list of arguments. if(i->Quoted) |