[CMake] howto re-run file(COPY signature ?
Dominique Belhachemi
domibel at cs.tu-berlin.de
Wed Nov 24 12:51:02 EST 2010
On Wed, 2010-11-24 at 10:55 +0100, Michael Hertling wrote:
> 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)
>
Thanks, I will see if this works for me.
> Because FILE(COPY ...) copies files and directories only if they are new
Does it mean it is a bug if FILE(COPY ...) doesn't copy new files?
> 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.
Thanks
Dominique
More information about the CMake
mailing list