[CMake] Reading the content of a file
Filipe Sousa
natros at gmail.com
Sun Feb 25 07:56:00 EST 2007
Timo Rumland wrote:
> Hello,
>
> what I must do is:
>
> 1. Read the content of a file
> 2. Modify the content (variable)
> 3. Write out the content into a new file
Have you tried CONFIGURE_FILE() ? You can use it to replace variables.
make version 2.5-20070219
CONFIGURE_FILE
Copy a file to another location and modify its contents.
CONFIGURE_FILE(InputFile OutputFile
[COPYONLY] [ESCAPE_QUOTES] [@ONLY])
The Input and Ouput files have to have full paths. This command
replaces any variables in the input file referenced as ${VAR} or @VAR@
with their values as determined by CMake. If a variable is not
defined, it will be replaced with nothing. If COPYONLY is specified,
then no variable expansion will take place. If ESCAPE_QUOTES is
specified then any substituted quotes will be C-style escaped. The
file will be configured with the current values of CMake variables.
If @ONLY is specified, only variables of the form @VAR@ will be
replaces and ${VAR} will be ignored. This is useful for configuring
scripts that use ${VAR}. Any occurrences of #cmakedefine VAR will be
replaced with either #define VAR or /* #undef VAR */ depending on the
setting of VAR in CMake
CONFIGURE_FILE(myfile ${CMAKE_CURRENT_BINARY_DIR}/myfile-copy)
--
Filipe Sousa
More information about the CMake
mailing list