[CMake] version number parsing
James Bigler
bigler at cs.utah.edu
Fri Sep 21 16:42:46 EDT 2007
James Bigler wrote:
> Is there an example I could look at to parse out the individual version
> numbers, once I get this string?
>
> STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" version-string ${output})
>
> I want to be able to get the three integers out of version-string.
I found some code in FindQt4.cmake:
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers
"${QT_MIN_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers
"${QT_MIN_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers
"${QT_MIN_VERSION}")
According to the documentation, I believe the ()'s create groups that can be
referenced by "\\1" or "\\2" and such.
James
More information about the CMake
mailing list