From 56125a3f363272568c578c7e329af37d97b24df0 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sun, 30 Sep 2012 10:44:18 +0200 Subject: list: add tests for CMP0007 behavior --- Tests/CMakeTests/List-Get-CMP0007-Warn.cmake | 6 ++++++ Tests/CMakeTests/ListTest.cmake.in | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 Tests/CMakeTests/List-Get-CMP0007-Warn.cmake diff --git a/Tests/CMakeTests/List-Get-CMP0007-Warn.cmake b/Tests/CMakeTests/List-Get-CMP0007-Warn.cmake new file mode 100644 index 0000000..0a9264f --- /dev/null +++ b/Tests/CMakeTests/List-Get-CMP0007-Warn.cmake @@ -0,0 +1,6 @@ +set(thelist "" NEW OLD) + +list(GET thelist 1 thevalue) +if (NOT thevalue STREQUAL "OLD") + message(SEND_ERROR "returned element '${thevalue}', but expected 'OLD'") +endif() diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in index 53559eb..f0ed70f 100644 --- a/Tests/CMakeTests/ListTest.cmake.in +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -155,6 +155,9 @@ foreach(cmd Remove_Item Reverse Remove_Duplicates Sort Remove_At) set(${cmd}-Nonexistent-List-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-${cmd}-Nonexistent-List.cmake:2 \\(list\\):.*sub-command ${Cmd} requires list to be present.*") endforeach() +set(Get-CMP0007-Warn-RESULT 0) +set(Get-CMP0007-Warn-STDERR ".*CMake Warning \\(dev\\) at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Get-CMP0007-Warn.cmake:3 \\(list\\):.*Policy CMP0007 is not set:.*") + check_cmake_test(List No-Arguments Length-Too-Many-Arguments @@ -170,4 +173,15 @@ check_cmake_test(List Sort-Nonexistent-List Remove_At-Nonexistent-List Remove_At-Invalid-Index + Get-CMP0007-Warn ) + +set(thelist "" NEW OLD) + +foreach (_pol ${thelist}) + cmake_policy(SET CMP0007 ${_pol}) + list(GET thelist 1 thevalue) + if (NOT thevalue STREQUAL _pol) + message(SEND_ERROR "returned element '${thevalue}', but expected '${_pol}'") + endif() +endforeach (_pol) -- cgit v0.12