diff options
author | Brad King <brad.king@kitware.com> | 2013-03-12 19:40:37 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-03-12 20:33:19 (GMT) |
commit | 1823ab4d76d8efe79bed85328a3f8c74c7d625bd (patch) | |
tree | c94f72f7b3918c53f142414c4c95826f115c272a /Tests/Module | |
parent | 51fc4fb3c1bd22f038b1d6b51e039296bbc258c3 (diff) | |
download | CMake-1823ab4d76d8efe79bed85328a3f8c74c7d625bd.zip CMake-1823ab4d76d8efe79bed85328a3f8c74c7d625bd.tar.gz CMake-1823ab4d76d8efe79bed85328a3f8c74c7d625bd.tar.bz2 |
ExternalData: Preserve escaped semicolons during argument expansion
The CMake language implicitly flattens lists so a ";" in a list element
must be escaped with a backslash. List expansion removes backslashes
escaping semicolons to leave raw semicolons in the values. Teach
ExternalData_Add_Test and ExternalData_Expand_Arguments to re-escape
semicolons found in list elements so the resulting argument lists work
as if constructed directly by the set() command.
For example:
ExternalData_Add_Test(Data NAME test1 COMMAND ... "a\\;b")
ExternalData_Expand_Arguments(Data args2 "c\\;d")
add_test(NAME test2 COMMAND ... ${args2})
should be equivalent to
set(args1 "a\\;b")
add_test(NAME test1 COMMAND ... ${args1})
set(args2 "c\\;d")
add_test(NAME test2 COMMAND ... ${args2})
which is equivalent to
add_test(NAME test1 COMMAND ... "a;b")
add_test(NAME test2 COMMAND ... "c;d")
Note that it is not possible to make ExternalData_Add_Test act exactly
like add_test when quoted arguments contain semicolons because the CMake
language flattens lists when constructing function ARGN values. This
re-escape approach at least allows test arguments to have semicolons.
While at it, teach ExternalData APIs to not transform "DATA{...;...}"
arguments because the contained semicolons are non-sensical.
Suggested-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Diffstat (limited to 'Tests/Module')
-rw-r--r-- | Tests/Module/ExternalData/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/Module/ExternalData/Data1Check.cmake | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt index a379dca..8312dca 100644 --- a/Tests/Module/ExternalData/CMakeLists.txt +++ b/Tests/Module/ExternalData/CMakeLists.txt @@ -35,6 +35,7 @@ ExternalData_Add_Test(Data1 -D Paired=DATA{PairedA.dat,PairedB.dat} -D Meta=DATA{MetaTop.dat,REGEX:Meta[ABC].dat} -D Directory=DATA{Directory/,A.dat,REGEX:[BC].dat} + -D "Semicolons=DATA{Data.dat}\\;DATA{Data.dat}" -P ${CMAKE_CURRENT_SOURCE_DIR}/Data1Check.cmake ) ExternalData_Add_Target(Data1) diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake index f40b76c..5770245 100644 --- a/Tests/Module/ExternalData/Data1Check.cmake +++ b/Tests/Module/ExternalData/Data1Check.cmake @@ -56,3 +56,13 @@ foreach(n A B C) message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") endif() endforeach() +list(LENGTH Semicolons len) +if("${len}" EQUAL 2) + foreach(file ${Semicolons}) + if(NOT EXISTS "${file}") + message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") + endif() + endforeach() +else() + message(SEND_ERROR "Semicolons value:\n ${Semicolons}\nis not a list of length 2.") +endif() |