[CMake] CMake copy files when they change to build dir

Tyler Roscoe tyler at cryptio.net
Fri Aug 7 10:25:39 EDT 2009


On Fri, Aug 07, 2009 at 10:08:16AM -0400, Eric Jonas wrote:
> I'd like to, as part of the build process, copy  test_foo.py
> to build/myproj/test_foo.py . That is, when I type "make", if
> src/myproj/test_foo.py differs from build/myproj/test_foo.py, copy it
> over. 
> 
> I've tried various incantations of add_custom_command but haven't been
> able to figure out the right thing to do. It seems like somehow
> I want the underlying generated Makefile to contain the relevant "cp"
> command, but thus far I have been unsuccessful. 

There is a FAQ entry about this that ought to work. Why don't you post
what you have so we can see where you're going wrong?

Also you can use cmake -E copy_if_different as the command part. It is
platform-independent, unlike cp.

tyler


More information about the CMake mailing list