[CMake] string replacement without external commands help (ex. sed)
Dizzy
dizzy at roedu.net
Tue Aug 21 11:10:03 EDT 2007
Hello
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:
I have recently started to test a cmake based build system for one of my
projects. I am interested in cmake mostly because currently we have to deal
with autotools for Unices (which even works for exotic ones such as BeOS) and
separate project files for Win32. With cmake theoretically should be easier
to manage a single build system for all these systems.
For the configuration files of the project with autotools we added a new rule
that said for building project.conf from project.conf.in we used sed to
replace some strings in project.conf.in with values from the build system
(dependent on the installation prefix and so on).
Doing this in cmake seems to me to require for one thing to use
add_custom_command(target project.conf command <sed invocation>). This would
probably work well enough on Unices but as I said with cmake I expect more,
ie I expect to have something portable for Win32 too without requiring win32
package builders to install a port of sed or something:)
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. Even if it's possible to chain configure_file() invocation with
add_custom_command() it would be nicer if there was some built-in cmake
support
Any idea?
Thanks!
--
Mihai RUSU Email: dizzy at roedu.net
"Linux is obsolete" -- AST
More information about the CMake
mailing list