[CMake] Reading the content of a file

Filipe Sousa natros at gmail.com
Sun Feb 25 09:31:25 EST 2007


Timo Rumland wrote:
> Hello,
> 
>> Have you tried CONFIGURE_FILE() ? You can use it to replace
>> variables.
>> CONFIGURE_FILE(myfile ${CMAKE_CURRENT_BINARY_DIR}/myfile-copy)
> 
> I can use CONFIGURE_FILE to copy the file, but I have to edit the
> content of the file (that goes beyond just replacing VARS in the
> file).
> 
> I must use a regex to do a string replace. The STRING function can do
> this, but only on variables, not files. So I have to read a file into
> a variable, change the variable with STRING and finally write it out
> into a new file.

In that case you have to quote the variable. ";" is used as a list 
separator.
file( WRITE ${filename2} "${tmp_filecontent}" )


> 
> Timo
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
> 



More information about the CMake mailing list