summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorArtur Ryt <artur.ryt@gmail.com>2018-11-30 23:51:05 +0100
committerBrad King <brad.king@kitware.com>2018-12-12 08:29:14 -0500
commitfe9a16c80fe921d2db66c0699b4197f85a281e7e (patch)
tree62b490a9996ed70715817bcaa76442f3abd4eaa6 /Source
parentdda4755b467db297b04cc1678e0d7c6035ad4c2f (diff)
downloadcmake-fe9a16c80fe921d2db66c0699b4197f85a281e7e.tar.gz
cmMakefile: Fix @CMAKE_CURRENT_LIST_LINE@ for ExpandVariablesInStringNew
Added check for variable name in @@ evaluation and test for configuring @CMAKE_CURRENT_LIST_LINE@ with new CMP0053 Fixes: #18646
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMakefile.cxx11
1 files changed, 9 insertions, 2 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9ed0dc36ad..5cd6ba5b94 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2727,6 +2727,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
cmState* state = this->GetCMakeInstance()->GetState();
+ static const std::string lineVar = "CMAKE_CURRENT_LIST_LINE";
do {
char inc = *in;
switch (inc) {
@@ -2739,7 +2740,6 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
const char* value = nullptr;
std::string varresult;
std::string svalue;
- static const std::string lineVar = "CMAKE_CURRENT_LIST_LINE";
switch (var.domain) {
case NORMAL:
if (filename && lookup == lineVar) {
@@ -2889,7 +2889,14 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
"abcdefghijklmnopqrstuvwxyz"
"0123456789/_.+-")) {
std::string variable(in + 1, nextAt - in - 1);
- std::string varresult = this->GetSafeDefinition(variable);
+
+ std::string varresult;
+ if (filename && variable == lineVar) {
+ varresult = std::to_string(line);
+ } else {
+ varresult = this->GetSafeDefinition(variable);
+ }
+
if (escapeQuotes) {
varresult = cmSystemTools::EscapeQuotes(varresult);
}