ExternalData: Allow ()-groups in series match regex
Refactor use of the ExternalData_SERIES_MATCH value to avoid assuming that it has no ()-groups that interfere with group indexing. Extend the Module.ExternalData test to cover this case.
This commit is contained in:
parent
4befecc77c
commit
175ed02207
|
@ -502,11 +502,14 @@ endmacro()
|
||||||
function(_ExternalData_arg_find_files pattern regex)
|
function(_ExternalData_arg_find_files pattern regex)
|
||||||
file(GLOB globbed RELATIVE "${top_src}" "${top_src}/${pattern}*")
|
file(GLOB globbed RELATIVE "${top_src}" "${top_src}/${pattern}*")
|
||||||
foreach(entry IN LISTS globbed)
|
foreach(entry IN LISTS globbed)
|
||||||
string(REGEX REPLACE "^(${regex})(\\.md5|)$" "\\1;\\2" tuple "${entry}")
|
if("x${entry}" MATCHES "^x(.*)(\\.md5)$")
|
||||||
list(LENGTH tuple len)
|
set(relname "${CMAKE_MATCH_1}")
|
||||||
if("${len}" EQUAL 2 AND NOT IS_DIRECTORY "${top_src}/${entry}")
|
set(alg "${CMAKE_MATCH_2}")
|
||||||
list(GET tuple 0 relname)
|
else()
|
||||||
list(GET tuple 1 alg)
|
set(relname "${entry}")
|
||||||
|
set(alg "")
|
||||||
|
endif()
|
||||||
|
if("x${relname}" MATCHES "^x${regex}$" AND NOT IS_DIRECTORY "${top_src}/${entry}")
|
||||||
set(name "${top_src}/${relname}")
|
set(name "${top_src}/${relname}")
|
||||||
set(file "${top_bin}/${relname}")
|
set(file "${top_bin}/${relname}")
|
||||||
if(alg)
|
if(alg)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
set(ExternalData_SERIES_PARSE "([0-9]+)(_\\.my\\.dat)$")
|
set(ExternalData_SERIES_PARSE "([0-9]+)(_\\.my\\.dat)$")
|
||||||
set(ExternalData_SERIES_MATCH "[0-9]+")
|
set(ExternalData_SERIES_MATCH "([0-9]+)")
|
||||||
ExternalData_Add_Test(Data2
|
ExternalData_Add_Test(Data2
|
||||||
NAME Data2Check
|
NAME Data2Check
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
|
Loading…
Reference in New Issue