diff options
author | Alexander Neundorf <neundorf@kde.org> | 2008-09-07 22:26:33 +0000 |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2008-09-07 22:26:33 +0000 |
commit | aac68ca8a37d02854eaaa1f711bfadb739a1bef4 (patch) | |
tree | 289e6137ce530519b6f88b5af289330aa3610790 | |
parent | 0a2a078fd1820f87c6828bfc69cffc91f08e44c3 (diff) | |
download | extra-cmake-modules-aac68ca8a37d02854eaaa1f711bfadb739a1bef4.tar.gz extra-cmake-modules-aac68ca8a37d02854eaaa1f711bfadb739a1bef4.tar.bz2 |
-save some regex matching and make the code easier readable: since cmake 2.6 regex matches are stored
in the variables CMAKE_MATCH_<number>, 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
-rw-r--r-- | modules/KDE4Macros.cmake | 28 |
1 files 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) |