mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
cmListCommand: handle empty lists for list(REMOVE_AT)
Treat an empty list as a list with no valid bounds and return an error message indicating that any given indices are out-of-bounds.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
CMake Error at EmptyRemoveAt0.cmake:2 \(list\):
|
||||
list REMOVE_AT given empty list
|
||||
list index: mylist, 0 out of range \(0, 0\)
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)$
|
||||
|
||||
1
Tests/RunCMake/list/REMOVE_AT-EmptyList-result.txt
Normal file
1
Tests/RunCMake/list/REMOVE_AT-EmptyList-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
4
Tests/RunCMake/list/REMOVE_AT-EmptyList-stderr.txt
Normal file
4
Tests/RunCMake/list/REMOVE_AT-EmptyList-stderr.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
^CMake Error at REMOVE_AT-EmptyList.cmake:2 \(list\):
|
||||
list index: nosuchlist, 0 out of range \(0, 0\)
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)$
|
||||
6
Tests/RunCMake/list/REMOVE_AT-EmptyList.cmake
Normal file
6
Tests/RunCMake/list/REMOVE_AT-EmptyList.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
set(nosuchlist "")
|
||||
list(REMOVE_AT nosuchlist 0)
|
||||
if (NOT DEFINED nosuchlist OR NOT nosuchlist STREQUAL "")
|
||||
message(FATAL_ERROR
|
||||
"list(REMOVE_AT) modified our list")
|
||||
endif ()
|
||||
@@ -1,4 +1,4 @@
|
||||
^CMake Error at REMOVE_AT-NotList.cmake:2 \(list\):
|
||||
list sub-command REMOVE_AT requires list to be present.
|
||||
list index: nosuchlist, 0 out of range \(0, 0\)
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)$
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
unset(nosuchlist)
|
||||
list(REMOVE_AT nosuchlist 0)
|
||||
if (DEFINED nosuchlist)
|
||||
message(FATAL_ERROR
|
||||
"list(REMOVE_AT) created our list")
|
||||
endif ()
|
||||
|
||||
@@ -22,6 +22,8 @@ run_cmake(REMOVE_DUPLICATES-TooManyArguments)
|
||||
run_cmake(REVERSE-TooManyArguments)
|
||||
run_cmake(SUBLIST-TooManyArguments)
|
||||
|
||||
run_cmake(REMOVE_AT-EmptyList)
|
||||
|
||||
run_cmake(FILTER-NotList)
|
||||
run_cmake(REMOVE_AT-NotList)
|
||||
run_cmake(REMOVE_DUPLICATES-NotList)
|
||||
|
||||
Reference in New Issue
Block a user