diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 0ef514c1f..6442c3ee9 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -502,11 +502,14 @@ endmacro() function(_ExternalData_arg_find_files pattern regex) file(GLOB globbed RELATIVE "${top_src}" "${top_src}/${pattern}*") foreach(entry IN LISTS globbed) - string(REGEX REPLACE "^(${regex})(\\.md5|)$" "\\1;\\2" tuple "${entry}") - list(LENGTH tuple len) - if("${len}" EQUAL 2 AND NOT IS_DIRECTORY "${top_src}/${entry}") - list(GET tuple 0 relname) - list(GET tuple 1 alg) + if("x${entry}" MATCHES "^x(.*)(\\.md5)$") + set(relname "${CMAKE_MATCH_1}") + set(alg "${CMAKE_MATCH_2}") + else() + 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(file "${top_bin}/${relname}") if(alg) diff --git a/Tests/Module/ExternalData/Data2/CMakeLists.txt b/Tests/Module/ExternalData/Data2/CMakeLists.txt index f8eedff64..e6d8767a6 100644 --- a/Tests/Module/ExternalData/Data2/CMakeLists.txt +++ b/Tests/Module/ExternalData/Data2/CMakeLists.txt @@ -1,5 +1,5 @@ set(ExternalData_SERIES_PARSE "([0-9]+)(_\\.my\\.dat)$") -set(ExternalData_SERIES_MATCH "[0-9]+") +set(ExternalData_SERIES_MATCH "([0-9]+)") ExternalData_Add_Test(Data2 NAME Data2Check COMMAND ${CMAKE_COMMAND}