[CMake] Generating source files..

Brad King brad.king at kitware.com
Wed May 25 09:41:29 EDT 2005


Shishir Ramam wrote:
> I'm trying to find a way to generate a source file from a CMakeLists file. 
> WRITE_FILE is not allowed. CONFIGURE_FILE only does
> a file copy. 
[snip]
> Actually on thinking about this, not sure why this should result in 
> an infinite loop. Perhaps someone in the know can explain?

The WRITE_FILE command is only not allowed for generating CMake source 
files that are used in the same CMake configuration process via an 
INCLUDE command.  CMake has dependencies so that it will re-run whenever 
one of the input files used during the configuration has changed.  If 
WRITE_FILE is used to write one of these files then it will always be 
newer than the last time the CMake configuration started.  When your 
build system runs it will always think CMake must rerun.

Using the command to write source files that are only used by the 
compiler is fine.  You can also use the FILE(WRITE ...) command which is 
the successor of WRITE_FILE.

-Brad


More information about the CMake mailing list