Commit fe9a16c8 authored by Artur Ryt's avatar Artur Ryt Committed by Brad King

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
parent dda4755b
......@@ -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);
}
......
......@@ -81,7 +81,7 @@ check_cmake_test(String
# Execute each test listed in StringTestScript.cmake:
#
set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/StringTestScript.cmake")
set(number_of_tests_expected 73)
set(number_of_tests_expected 74)
include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake")
execute_all_script_tests(${scriptname} number_of_tests_executed)
......
......@@ -54,6 +54,9 @@ elseif(testname STREQUAL configure_line_number_CMP0053_new) # pass
elseif(testname STREQUAL configure_line_number_CMP0053_old_use_at) # pass
test_configure_line_number("\@CMAKE_CURRENT_LIST_LINE\@" OLD)
elseif(testname STREQUAL configure_line_number_CMP0053_new_use_at) # pass
test_configure_line_number("\@CMAKE_CURRENT_LIST_LINE\@" NEW)
elseif(testname STREQUAL configure_bogus) # fail
string(CONFIGURE "this is @testname@" v ESCAPE_QUOTES BOGUS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment