[CMake] add_custom_command weirdness

Michael Wild themiwi at gmail.com
Wed Apr 7 07:47:08 EDT 2010


On 7. Apr, 2010, at 13:26 , Christoph Höger wrote:

> Hi all,
> 
> here comes the testcase:
> 
> project(cmakeBug)
> 
> set(src ${PROJECT_SOURCE_DIR}/src)
> set(inc ${PROJECT_SOURCE_DIR}/inc)
> 
> add_custom_command(OUTPUT ${inc}/test.h ${inc}/test2.h ${src}/test.c
> 		COMMAND echo "//foo" > ${inc}/test.h
> 		COMMAND echo "//foo" > ${inc}/test2.h
> 		COMMAND echo "//bar" > ${src}/test.c
> )
> 
> add_executable(test ${src}/main.c ${src}/test.c)
> 
> 
> Under windows XP cmake 2.8 the first file (test.h) will be always deleted when cmake is invoked, while the other ones still exist.
> This does not happen, when add_custom_command has only one output file. Obviously a bug.

Hm, I don't see this behavior with CMake 2.8.1 on Mac OS X. When reading this I thought this might be related to http://www.cmake.org/Bug/view.php?id=10048, but as I can't reproduce it I'm a bit lost. What generator are you using?

As an aside: You should NEVER (as in "verboten") write to the source tree, only to the binary tree.

Michael



More information about the CMake mailing list