diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2012-08-19 11:54:56 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eike@sf-mail.de> | 2012-08-19 11:54:56 (GMT) |
commit | 4be6783711b2ff510c3449c5de22d35663d8bfc1 (patch) | |
tree | d43959dacd4cf3db3e624d2976468c52e5bf172a /Modules/FindArmadillo.cmake | |
parent | d46f8afae98cd8f50cff9915a5a9dc680b9e0518 (diff) | |
download | CMake-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/FindArmadillo.cmake')
-rw-r--r-- | Modules/FindArmadillo.cmake | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/FindArmadillo.cmake b/Modules/FindArmadillo.cmake index aad22d2..0bd3e6c 100644 --- a/Modules/FindArmadillo.cmake +++ b/Modules/FindArmadillo.cmake @@ -58,7 +58,7 @@ if(ARMADILLO_INCLUDE_DIR) if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp") # Read and parse armdillo version header file for version number - file(READ "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp" _armadillo_HEADER_CONTENTS) + file(STRINGS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp" _armadillo_HEADER_CONTENTS REGEX "#define ARMA_VERSION_[A-Z]+ ") string(REGEX REPLACE ".*#define ARMA_VERSION_MAJOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MAJOR "${_armadillo_HEADER_CONTENTS}") string(REGEX REPLACE ".*#define ARMA_VERSION_MINOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MINOR "${_armadillo_HEADER_CONTENTS}") string(REGEX REPLACE ".*#define ARMA_VERSION_PATCH ([0-9]+).*" "\\1" ARMADILLO_VERSION_PATCH "${_armadillo_HEADER_CONTENTS}") @@ -66,6 +66,7 @@ if(ARMADILLO_INCLUDE_DIR) # WARNING: The number of spaces before the version name is not one. string(REGEX REPLACE ".*#define ARMA_VERSION_NAME\ +\"([0-9a-zA-Z\ _-]+)\".*" "\\1" ARMADILLO_VERSION_NAME "${_armadillo_HEADER_CONTENTS}") + unset(_armadillo_HEADER_CONTENTS) endif() set(ARMADILLO_VERSION_STRING "${ARMADILLO_VERSION_MAJOR}.${ARMADILLO_VERSION_MINOR}.${ARMADILLO_VERSION_PATCH}") |