summaryrefslogtreecommitdiff
path: root/Modules/ExternalData.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2014-04-06 21:30:00 +0200
committerRolf Eike Beer <eike@sf-mail.de>2014-04-14 18:16:58 +0200
commit2622bc3f65162bf6d6cb5838da6999f8b5ca75cf (patch)
treed90da340e1dd6e104f8b6c7344f6b38e4d1f03c8 /Modules/ExternalData.cmake
parent11a6b3d59ad2f75890fcdc42ec13c7a9ee1463f0 (diff)
downloadcmake-2622bc3f65162bf6d6cb5838da6999f8b5ca75cf.tar.gz
Clean up usage of if(... MATCHES regex) followed string(REGEX REPLACE regex)
The matches have already been calculated and can simply be taken from CMAKE_MATCH_n variables. This avoids multiple compilations of the same or very similar regular expressions.
Diffstat (limited to 'Modules/ExternalData.cmake')
-rw-r--r--Modules/ExternalData.cmake10
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake
index 1e2698c10c..ee206935ec 100644
--- a/Modules/ExternalData.cmake
+++ b/Modules/ExternalData.cmake
@@ -292,8 +292,7 @@ function(ExternalData_expand_arguments target outArgsVar)
foreach(piece IN LISTS pieces)
if("x${piece}" MATCHES "^x${data_regex}$")
# Replace this DATA{}-piece with a file path.
- string(REGEX REPLACE "${data_regex}" "\\1" data "${piece}")
- _ExternalData_arg("${target}" "${piece}" "${data}" file)
+ _ExternalData_arg("${target}" "${piece}" "${CMAKE_MATCH_1}" file)
set(outArg "${outArg}${file}")
else()
# No replacement needed for this piece.
@@ -428,10 +427,9 @@ function(_ExternalData_arg target arg options var_file)
set(associated_files "")
set(associated_regex "")
foreach(opt ${options})
- if("x${opt}" MATCHES "^xREGEX:[^:/]+$")
- # Regular expression to match associated files.
- string(REGEX REPLACE "^REGEX:" "" regex "${opt}")
- list(APPEND associated_regex "${regex}")
+ # Regular expression to match associated files.
+ if("x${opt}" MATCHES "^xREGEX:([^:/]+)$")
+ list(APPEND associated_regex "${CMAKE_MATCH_1}")
elseif(opt STREQUAL ":")
# Activate series matching.
set(series_option "${opt}")