[CMake] A CMake language peculiarity I have just discovered

Brandon J. Van Every bvanevery at gmail.com
Sat Sep 16 19:52:05 EDT 2006


Alan W. Irwin wrote:
> I am pleased with the way that CMake normally defaults to writing 
> files to
> the build tree.  This default behaviour encourages users to keep a clean,
> unmolested source tree.
>
> Thus, I was surprised recently to discover that
>
> FILE(WRITE filename "message to write"... )
>
> created by default a file called filename in the source tree.
>
> Of course, to keep a clean source tree you can use
> ${CMAKE_CURRENT_BINARY_DIR}/filename which I was forced to do.  But I was
> wondering if this default contamination of the source tree by 
> FILE(WRITE...
> was a recently introduced bug (I use cmake-2.4.3) that should be 
> fixed? Or
> is there some logical reason which I am missing for putting FILE(WRITE...
> results in the source tree by default?

I think the problem is, CMake knows about .c and .h files, but not other 
kinds of files.  So it has automagical behavior for C/C++ code as far as 
what directories those end up in by default, but it does not have it for 
arbitrary types of files.  I've always qualified the hell out of my 
filenames.  My jury's out on whether I should be expected to do that or not.


Cheers,
Brandon Van Every



More information about the CMake mailing list