[CMake] Wanted : Macro to copy files if touched

John Biddiscombe biddisco at cscs.ch
Fri Jan 13 08:51:42 EST 2006


Hello all,

I have a directory with some text files in that I need to copy to my 
build tree, currently I copy them like this

FILE(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/resources )
FOREACH(file ${FILES_TO_BE_COPIED} )
  GET_FILENAME_COMPONENT(name ${file} NAME)
  IF (NOT EXISTS ${EXECUTABLE_OUTPUT_PATH}/resources/${name} )
    CONFIGURE_FILE( ${file} ${EXECUTABLE_OUTPUT_PATH}/resources COPYONLY)
  ENDIF (NOT EXISTS ${EXECUTABLE_OUTPUT_PATH}/resources/${name} )
ENDFOREACH(file) 

which copies them only if they are not already there. I'm making a lot 
of tweaks to them at the moment and I'd like to copy them if they're not 
there or if the time in the source tree is is newer than the previously 
copied version.
Before I start writing a new macro, if anyone has already got a snippet 
which does this, I'd love to use it. I'm guessing I'd need to set up a 
custom rule, add dependencies etc, I'm sure there must be examples out 
there.

thanks

JB

-- 
John Biddiscombe,                            email:biddisco @ cscs.ch
http://www.cscs.ch/about/BJohn.php
CSCS, Swiss National Supercomputing Centre  | Tel:  +41 (91) 610.82.07
Via Cantonale, 6928 Manno, Switzerland      | Fax:  +41 (91) 610.82.82




More information about the CMake mailing list