[CMake] Re: string replacement without external commands help (ex. sed)

Matthew Woehlke mw_triad at users.sourceforge.net
Mon Aug 27 21:04:02 EDT 2007


Dizzy wrote:
> Short version:
> Is there some built-in support in cmake for string replacement in files (ie to 
> generate a file from another by replacing a given string with another, 
> similar to configure_file() but more general) and could this string 
> replacement operation be used as a "command" for add_custom_command() ?
> 
> Long version:
> [snip]
> I noticed that configure_file() can be used to generate a file from another by 
> replacing variable placeholders. It may not be as general as using sed to 
> replace any string sequence but we could make it work (initially we could 
> modify project.conf.in to have variable placehoders and use configure_file() 
> to replace them). But then I have no idea how to use configure_file() from 
> within add_custom_command() as I understand the later wants external commands 
> to execute.

Why do you need to use CONFIGURE_FILE in a custom command? If you 
absolutely MUST do this, you can always FILE(WRITE ...) a cmake script 
and run that in your custom command.

-- 
Matthew
Microsoft: driving people fscking insane...



More information about the CMake mailing list