summaryrefslogtreecommitdiffstats
path: root/Modules/FindLibLZMA.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2012-08-19 11:54:56 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2012-08-19 11:54:56 (GMT)
commit4be6783711b2ff510c3449c5de22d35663d8bfc1 (patch)
treed43959dacd4cf3db3e624d2976468c52e5bf172a /Modules/FindLibLZMA.cmake
parentd46f8afae98cd8f50cff9915a5a9dc680b9e0518 (diff)
downloadCMake-4be6783711b2ff510c3449c5de22d35663d8bfc1.zip
CMake-4be6783711b2ff510c3449c5de22d35663d8bfc1.tar.gz
CMake-4be6783711b2ff510c3449c5de22d35663d8bfc1.tar.bz2
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/FindLibLZMA.cmake')
-rw-r--r--Modules/FindLibLZMA.cmake3
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake
index 37cace8..f8ea18b 100644
--- a/Modules/FindLibLZMA.cmake
+++ b/Modules/FindLibLZMA.cmake
@@ -33,13 +33,14 @@ find_path(LIBLZMA_INCLUDE_DIR lzma.h )
find_library(LIBLZMA_LIBRARY lzma)
if(LIBLZMA_INCLUDE_DIR AND EXISTS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h")
- file(READ "${LIBLZMA_INCLUDE_DIR}/lzma/version.h" LIBLZMA_HEADER_CONTENTS)
+ file(STRINGS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h" LIBLZMA_HEADER_CONTENTS REGEX "#define LZMA_VERSION_[A-Z]+ [0-9]+")
string(REGEX REPLACE ".*#define LZMA_VERSION_MAJOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MAJOR "${LIBLZMA_HEADER_CONTENTS}")
string(REGEX REPLACE ".*#define LZMA_VERSION_MINOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MINOR "${LIBLZMA_HEADER_CONTENTS}")
string(REGEX REPLACE ".*#define LZMA_VERSION_PATCH ([0-9]+).*" "\\1" LIBLZMA_VERSION_PATCH "${LIBLZMA_HEADER_CONTENTS}")
set(LIBLZMA_VERSION_STRING "${LIBLZMA_VERSION_MAJOR}.${LIBLZMA_VERSION_MINOR}.${LIBLZMA_VERSION_PATCH}")
+ unset(LIBLZMA_HEADER_CONTENTS)
endif()
# We're using new code known now as XZ, even library still been called LZMA