mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
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>
69 lines
2.2 KiB
CMake
69 lines
2.2 KiB
CMake
file(STRINGS "${Data}" lines LIMIT_INPUT 1024)
|
|
if(NOT "x${lines}" STREQUAL "xInput file already transformed.")
|
|
message(SEND_ERROR "Input file:\n ${Data}\ndoes not have expected content, but [[${lines}]]")
|
|
endif()
|
|
if(DEFINED DataSpace)
|
|
file(STRINGS "${DataSpace}" lines LIMIT_INPUT 1024)
|
|
if(NOT "x${lines}" STREQUAL "xInput file already transformed.")
|
|
message(SEND_ERROR "Input file:\n ${DataSpace}\ndoes not have expected content, but [[${lines}]]")
|
|
endif()
|
|
endif()
|
|
set(SeriesAn1 "1\\.dat")
|
|
set(SeriesBn1 "_1\\.dat")
|
|
set(SeriesCn1 "\\.1\\.dat")
|
|
set(SeriesDn1 "-1\\.dat")
|
|
set(SeriesAl 1 2 3)
|
|
set(SeriesBl _1 _2 _3)
|
|
set(SeriesCl .1 .2 .3)
|
|
set(SeriesDl -1 -2 -3)
|
|
foreach(s A B C D)
|
|
foreach(n "" ${Series${s}l})
|
|
string(REGEX REPLACE "\\.dat$" "${n}.dat" file "${Series${s}}")
|
|
if(NOT EXISTS "${file}")
|
|
message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!")
|
|
endif()
|
|
endforeach()
|
|
endforeach()
|
|
foreach(s A B C D)
|
|
foreach(n ${Series${s}l})
|
|
string(REGEX REPLACE "${Series${s}n1}$" "${n}.dat" file "${Series${s}n}")
|
|
if(NOT EXISTS "${file}")
|
|
message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!")
|
|
endif()
|
|
endforeach()
|
|
endforeach()
|
|
foreach(n .1 .2 .3 .4)
|
|
string(REGEX REPLACE "\\.1\\.dat$" "${n}.dat" file "${SeriesMixed}")
|
|
if(NOT EXISTS "${file}")
|
|
message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!")
|
|
endif()
|
|
endforeach()
|
|
foreach(n A B)
|
|
string(REGEX REPLACE "A\\.dat$" "${n}.dat" file "${Paired}")
|
|
if(NOT EXISTS "${file}")
|
|
message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!")
|
|
endif()
|
|
endforeach()
|
|
foreach(n Top A B C)
|
|
string(REGEX REPLACE "Top\\.dat$" "${n}.dat" file "${Meta}")
|
|
if(NOT EXISTS "${file}")
|
|
message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!")
|
|
endif()
|
|
endforeach()
|
|
foreach(n A B C)
|
|
set(file "${Directory}/${n}.dat")
|
|
if(NOT EXISTS "${file}")
|
|
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()
|