[Cmake] Capture regular expressions

Filipe Sousa filipe.gr.sousa at alunos.ipb.pt
Fri, 30 Apr 2004 17:48:49 +0100


--Boundary-02=_5NokAFFX3pUQOgp
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I wrote my own FindQt.cmake so that I could find the right qt lib on Window=
s.=20
I need to extract the version from global.h. I managed that using two STRIN=
G=20
command, but I would like to capture version around parentheses with regula=
r=20
expressions using only one STRING command. Is this possible with cmake?

        .
        .
        .
# find qt.h
=46IND_PATH(QT_INC qt.h ${QT_DIR}/include /usr/share/qt3/include)
IF(QT_INC)
  	# Find '#define QT_VERSION_STR   "3.3.2"' and extract version
	FILE(READ ${QT_INC}/qglobal.h GLOBAL_H)
	STRING(REGEX MATCH "#define[\\t\\ ]+QT_VERSION_STR[\\t\\ ]+\"([0-9]+\\.
[0-9]+\\.[0-9]+)\"" qt_version "${GLOBAL_H}")
	STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" QT_VERSION "${qt_version}")
ENDIF(QT_INC)

IF(WIN32)
	STRING(REGEX REPLACE "\\." "" lib_version "${QT_VERSION}")
  	FIND_LIBRARY(QT_LIB qt-mt${lib_version} ${QT_DIR}/lib)
        .
        .
        .

Thanks,
=46ilipe Sousa


--Boundary-02=_5NokAFFX3pUQOgp
Content-Type: application/pgp-signature
Content-Description: signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQBAkoN5bQdNYqwwwCwRAvHfAJwPZULJWe4m3rs7dxezCXjh1Tfw9wCfbJO4
KtmYFDH+eDZg+xnlUKNQ3OY=
=lgAW
-----END PGP SIGNATURE-----

--Boundary-02=_5NokAFFX3pUQOgp--