[CMake] Copying data files from source tree to binary tree during the build

Asmodehn Shade asmodehn at gmail.com
Tue Jan 10 21:32:34 EST 2006


Hello everyone,

I have recently come across a little problem using CMake for my own C++
project.

I have a src tree like :
SOURCE_DIR/CMakeLists.txt
SOURCE_DIR/src/ (*.cpp)
SOURCE_DIR/include/ (*.h)
SOURCE_DIR/data/ (*.*)
SOURCE_DIR/test/ (*.cpp)

I want to build it into a binary tree organised in a quite similar way, in
case of users using the same value for SOURCE_DIR and BINARY_DIR to build.
But it is hard to keep the binary tree consistent with different compilers.

Anyway with visual studio I end up with smoething like
BINARY_DIR/<Target>.dir/
BINARY_DIR/CMakeFile/
BINARY_DIR/CMakeTmp/
BINARY_DIR/debug/ (Targets outputs)

Then I want to move the files within /data that are needed to be able to run
and debug my tests, without actually going nto the install part of my
project yet.
Therefore I assume that the right way to do it, would be to add a custom
command for the build of the needed targets with the corresponding datafile.
But do I really need to do a

IF(WIN32) xcopy ...
IF (UNIX) cp ...
etc. ???

Any idea about how should I do that properly ?

Thanks a lot !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20060111/8df91fb8/attachment.html


More information about the CMake mailing list