summaryrefslogtreecommitdiff
path: root/Modules/KDE3Macros.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2012-08-19 13:54:56 +0200
committerRolf Eike Beer <eike@sf-mail.de>2012-08-19 13:54:56 +0200
commit4be6783711b2ff510c3449c5de22d35663d8bfc1 (patch)
treed43959dacd4cf3db3e624d2976468c52e5bf172a /Modules/KDE3Macros.cmake
parentd46f8afae98cd8f50cff9915a5a9dc680b9e0518 (diff)
downloadcmake-4be6783711b2ff510c3449c5de22d35663d8bfc1.tar.gz
read less from version headers into variables
Instead of reading the whole file using file(READ) and later matching on the whole file use file(STRINGS ... REGEX) to get only those lines we are interested in at all. This will make the list much smaller (good for debugging) and also the regular expressions will need to match on much smaller strings. Also unset the content variables once they are not used anymore.
Diffstat (limited to 'Modules/KDE3Macros.cmake')
-rw-r--r--Modules/KDE3Macros.cmake35
1 files changed, 17 insertions, 18 deletions
diff --git a/Modules/KDE3Macros.cmake b/Modules/KDE3Macros.cmake
index 6d6cdb0d2e..07864f5d87 100644
--- a/Modules/KDE3Macros.cmake
+++ b/Modules/KDE3Macros.cmake
@@ -223,31 +223,30 @@ macro(KDE3_AUTOMOC)
if (EXISTS ${_abs_FILE} AND NOT _skip)
- file(READ ${_abs_FILE} _contents)
+ file(STRINGS ${_abs_FILE} _match REGEX "#include +[^ ]+\\.moc[\">]")
get_filename_component(_abs_PATH ${_abs_FILE} PATH)
- string(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}")
- if(_match)
- foreach (_current_MOC_INC ${_match})
- string(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
+ foreach (_current_MOC_INC IN LISTS _match)
+ string(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
- get_filename_component(_basename ${_current_MOC} NAME_WE)
-# set(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
- set(_header ${_abs_PATH}/${_basename}.h)
- set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
+ get_filename_component(_basename ${_current_MOC} NAME_WE)
+# set(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
+ set(_header ${_abs_PATH}/${_basename}.h)
+ set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
- add_custom_command(OUTPUT ${_moc}
- COMMAND ${QT_MOC_EXECUTABLE}
- ARGS ${_header} -o ${_moc}
- DEPENDS ${_header}
- )
+ add_custom_command(OUTPUT ${_moc}
+ COMMAND ${QT_MOC_EXECUTABLE}
+ ARGS ${_header} -o ${_moc}
+ DEPENDS ${_header}
+ )
- ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
-
- endforeach ()
- endif()
+ ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
+ endforeach ()
+ unset(_match)
+ unset(_header)
+ unset(_moc)
endif ()
endforeach ()
endmacro()