[CMake] STRING(REPLACE <match_expression> bugged?

Brad King brad.king at kitware.com
Mon Jun 12 15:33:07 EDT 2006


Brandon J. Van Every wrote:
> The CMake 2.4.2 docs specify:
> 
> STRING(REPLACE <match_expression>
> <replace_expression> <output variable>
> <input> [<input>...])
> 
> <match_expression> is not defined elsewhere in the document.  I presume 
> it is somehow different than a <regular_expression>.  It appears that a 
> <match_expression> of "@VARIABLE_NAME@" will not match anything in a 
> file.  Is this expected behavior or a bug?  If it's expected behavior, 
> it should be documented.
[snip]
> STRING(REPLACE "@INSTALL_HOME@" "${INSTALL_HOME}" input "${input}")

The @INSTALL_HOME@ text is being treated as a variable reference, so the 
STRING command gets the value of the INSTALL_HOME variable as the match 
expression.  Try this:

SET(AT "@")
STRING(REPLACE "${AT}INSTALL_HOME${AT}" "${INSTALL_HOME}" input "${input}")

-Brad



More information about the CMake mailing list