From aac68ca8a37d02854eaaa1f711bfadb739a1bef4 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sun, 7 Sep 2008 22:26:33 +0000 Subject: -save some regex matching and make the code easier readable: since cmake 2.6 regex matches are stored in the variables CMAKE_MATCH_, so we have to match the regex only once instead of multiple times and can then just use the stored matches Alex svn path=/trunk/KDE/kdelibs/; revision=858379 --- modules/KDE4Macros.cmake | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/modules/KDE4Macros.cmake b/modules/KDE4Macros.cmake index c99a4960..57e48993 100644 --- a/modules/KDE4Macros.cmake +++ b/modules/KDE4Macros.cmake @@ -369,10 +369,12 @@ macro (KDE4_INSTALL_ICONS _defaultpath ) # first the png icons file(GLOB _icons *.png) foreach (_current_ICON ${_icons} ) - string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\1" _type "${_current_ICON}") - string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\2" _size "${_current_ICON}") - string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\3" _group "${_current_ICON}") - string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\4" _name "${_current_ICON}") + # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty + string(REGEX MATCH "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" _dummy "${_current_ICON}") + set(_type "${CMAKE_MATCH_1}") + set(_size "${CMAKE_MATCH_2}") + set(_group "${CMAKE_MATCH_3}") + set(_name "${CMAKE_MATCH_4}") set(_theme_GROUP ${_KDE4_ICON_THEME_${_type}}) if( _theme_GROUP) @@ -385,10 +387,12 @@ macro (KDE4_INSTALL_ICONS _defaultpath ) # mng icons file(GLOB _icons *.mng) foreach (_current_ICON ${_icons} ) - string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" "\\1" _type "${_current_ICON}") - string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" "\\2" _size "${_current_ICON}") - string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" "\\3" _group "${_current_ICON}") - string(REGEX REPLACE "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" "\\4" _name "${_current_ICON}") + # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty + string(REGEX MATCH "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" _dummy "${_current_ICON}") + set(_type "${CMAKE_MATCH_1}") + set(_size "${CMAKE_MATCH_2}") + set(_group "${CMAKE_MATCH_3}") + set(_name "${CMAKE_MATCH_4}") set(_theme_GROUP ${_KDE4_ICON_THEME_${_type}}) if( _theme_GROUP) @@ -401,9 +405,11 @@ macro (KDE4_INSTALL_ICONS _defaultpath ) # and now the svg icons file(GLOB _icons *.svgz) foreach (_current_ICON ${_icons} ) - string(REGEX REPLACE "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" "\\1" _type "${_current_ICON}") - string(REGEX REPLACE "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" "\\2" _group "${_current_ICON}") - string(REGEX REPLACE "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" "\\3" _name "${_current_ICON}") + # since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty + string(REGEX MATCH "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" _dummy "${_current_ICON}") + set(_type "${CMAKE_MATCH_1}") + set(_group "${CMAKE_MATCH_2}") + set(_name "${CMAKE_MATCH_3}") set(_theme_GROUP ${_KDE4_ICON_THEME_${_type}}) if( _theme_GROUP) -- cgit v1.2.1