summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2016-09-28 16:07:39 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-28 18:18:20 (GMT)
commit41291b20f3881cac781e5e628f8b892b29c7b39c (patch)
treee36f76ea8719cef0580d1cfdbae112e5e4d48b27 /Tests/RunCMake
parent8f25f37676cb860348738eff4dfb1c3b8bae0b59 (diff)
downloadCMake-41291b20f3881cac781e5e628f8b892b29c7b39c.zip
CMake-41291b20f3881cac781e5e628f8b892b29c7b39c.tar.gz
CMake-41291b20f3881cac781e5e628f8b892b29c7b39c.tar.bz2
cmake_parse_arguments: Fix PARSE_ARGV multi-value argument handling
The `PARSE_ARGV` mode was recently added to help functions properly parse their arguments even when those arguments may be quoted and contain literal `;` in their values. Fix the implementation to encode `;`s in reported multi-value arguments and in `UNPARSED_ARGUMENTS` so that `;`s in the individual values are preserved in the lists. This allows clients to access all their argument values correctly.
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/cmake_parse_arguments/ArgvN.cmake22
1 files changed, 20 insertions, 2 deletions
diff --git a/Tests/RunCMake/cmake_parse_arguments/ArgvN.cmake b/Tests/RunCMake/cmake_parse_arguments/ArgvN.cmake
index 61bde03..63a1b01 100644
--- a/Tests/RunCMake/cmake_parse_arguments/ArgvN.cmake
+++ b/Tests/RunCMake/cmake_parse_arguments/ArgvN.cmake
@@ -1,5 +1,15 @@
include(${CMAKE_CURRENT_LIST_DIR}/test_utils.cmake)
+function(test_multi list)
+ set(i 0)
+ foreach(value IN LISTS ${list})
+ math(EXPR j "${i} + 1")
+ set(${list}[${i}] "${value}")
+ TEST(${list}[${i}] "${ARGV${j}}")
+ set(i ${j})
+ endforeach()
+endfunction()
+
function(test1)
cmake_parse_arguments(PARSE_ARGV 0
pref "OPT1;OPT2" "SINGLE1;SINGLE2" "MULTI1;MULTI2")
@@ -23,8 +33,16 @@ function(test2 arg1)
TEST(pref_OPT2 FALSE)
TEST(pref_SINGLE1 "foo;bar")
TEST(pref_SINGLE2 UNDEFINED)
- TEST(pref_MULTI1 bar foo bar)
+ test_multi(pref_MULTI1 bar "foo;bar")
TEST(pref_MULTI2 UNDEFINED)
TEST(pref_UNPARSED_ARGUMENTS UNDEFINED)
endfunction()
-test2("first named" OPT1 SINGLE1 "foo;bar" MULTI1 bar foo bar)
+test2("first named" OPT1 SINGLE1 "foo;bar" MULTI1 bar "foo;bar")
+
+function(test3 arg1)
+ cmake_parse_arguments(PARSE_ARGV 0
+ pref "" "" "")
+
+ test_multi(pref_UNPARSED_ARGUMENTS "foo;bar" dog cat)
+endfunction()
+test3("foo;bar" dog cat)