[CMake] "STRING( REGEX REPLACE" Question

Brad King brad.king at kitware.com
Thu Apr 21 13:58:56 EDT 2005


Jens Henrik Goebbert wrote:
> Hi
> 
> I try to write an "FindQt4.cmake"-File and need to know how to replace "../.." 
> with ${QT_DIR}
> 
> I tried this:
> STRING(REGEX REPLACE "\.\./\.\." "${QT_DIR}" QT_QGLOBAL_FILE 
> "${QT_QGLOBAL_H_FILE})
> 
> But the regexpression does not get recognised ... even though I think it's 
> correct.

You need an extra level of backslashes to get through CMake syntax first 
and then regex syntax:

STRING(REGEX REPLACE "\\.\\./\\.\\." ...)

-Brad


More information about the CMake mailing list