[Cmake] Capture regular expressions
Brad King
brad.king at kitware.com
Mon, 03 May 2004 09:19:52 -0400
Filipe Sousa wrote:
> I wrote my own FindQt.cmake so that I could find the right qt lib on Windows.
> I need to extract the version from global.h. I managed that using two STRING
> command, but I would like to capture version around parentheses with regular
> expressions using only one STRING command. Is this possible with cmake?
What do you mean by "version around parentheses"? Code like this is
supported:
STRING(REGEX REPLACE "#define[\\t\\ ]+QT_VERSION_STR[\\t\\
]+\"([0-9]+\\.[0-9]+\\.[0-9]+)\"" "\\1" qt_version "${VERSION_STR}")
Note the "\\1" in the replace expression. The two backslashes make it
through argument processing as a single backslash, and then the "\1" is
replaced by the part of the string matched inside the parentheses.
-Brad