list(POP_FRONT): Fix always assigning first item to output vars

Fixes: #19436
This commit is contained in:
Alex Turbov 2019-06-30 12:23:35 +03:00
parent 753373579e
commit 822abf1265
No known key found for this signature in database
GPG Key ID: 8BEDB7D11F95D5E3
2 changed files with 14 additions and 1 deletions

View File

@ -344,7 +344,7 @@ bool cmListCommand::HandlePopFrontCommand(std::vector<std::string> const& args)
auto vi = varArgsExpanded.begin();
for (; vi != varArgsExpanded.end() && ai != args.cend(); ++ai, ++vi) {
assert(!ai->empty());
this->Makefile->AddDefinition(*ai, varArgsExpanded.front().c_str());
this->Makefile->AddDefinition(*ai, vi->c_str());
}
varArgsExpanded.erase(varArgsExpanded.begin(), vi);
// Undefine the rest variables if the list gets empty earlier...

View File

@ -77,3 +77,16 @@ endif()
if(NOT test STREQUAL "two")
message(FATAL_ERROR "`test` has unexpected value `${test}`")
endif()
# BUG 19436
set(myList a b c)
list(POP_FRONT myList first second)
if(NOT first STREQUAL "a")
message(FATAL_ERROR "BUG#19436: `first` has unexpected value `${first}`")
endif()
if(NOT second STREQUAL "b")
message(FATAL_ERROR "BUG#19436: `second` has unexpected value `${second}`")
endif()
if(NOT myList STREQUAL "c")
message(FATAL_ERROR "BUG#19436: `myList` has unexpected value `${myList}`")
endif()