On 11/24/2010 04:44 AM, Dominique Belhachemi wrote:
> Hello,
> 
> I am using the following command in my CMakeLists.txt file to copy a
> directory with all sub-directories from the source tree to a directory
> in the binary tree.
> 
> file(COPY ${SRCDIR}
>   DESTINATION ${CMAKE_BINARY_DIR}/${DSTDIR}/
>   PATTERN .svn EXCLUDE
> )
> 
> After adding this line to CMakeLists.txt and typing 'make' the command
> is working like expected. But after adding a new file to ${SRCDIR} and
> typing 'make' again, the new file doesn't get copied. I have to do a
> 'touch CMakeLists.txt' first.
> 
> Is there a way to enforce the execution?

You might outsource the FILE(COPY ...) command to a CMake script which
is invoked by a custom target, e.g. as in the following CMakeLists.txt:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(COPYTREE NONE)
ADD_CUSTOM_TARGET(copytree ALL
    ${CMAKE_COMMAND}
    -DSRC=${CMAKE_SOURCE_DIR}
    -DDST=/tmp/${PROJECT_NAME}
    -P ${CMAKE_SOURCE_DIR}/copytree.cmake
)

The ${CMAKE_SOURCE_DIR}/copytree.cmake script simply looks like:

FILE(COPY ${SRC} DESTINATION ${DST} PATTERN .svn EXCLUDE)

Because FILE(COPY ...) copies files and directories only if they are new
or have been touched you can probably afford the script's execution each
time you build; use ADD_DEPENDENCIES() to ensure that the script runs at
the right time.

Regards,

Michael
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to