[CMake] Wanted : Macro to copy files if touched
Andy Cedilnik
andy.cedilnik at kitware.com
Tue Jan 17 09:05:20 EST 2006
Hi,
Couple of things. The CONFIGURE_FILE approach is more correct because:
1. It does copy_if_different already
2. It does dependency checking
So, the real code should just say:
FILE(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/resources )
FOREACH(file ${FILES_TO_BE_COPIED} )
GET_FILENAME_COMPONENT(name ${file} NAME)
CONFIGURE_FILE( ${file} ${EXECUTABLE_OUTPUT_PATH}/resources COPYONLY)
ENDFOREACH(file)
Andy
Filipe Sousa wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>John Biddiscombe wrote:
>
>
>>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.
>>
>>
>
>I suggest using cmake -E copy_if_different to copy the file if they are
>different
>
>fsousa at neptuno ~ $ cmake -E
>CMake Error: cmake version 2.3-20060113
>Usage: cmake -E [command] [arguments ...]
>Available commands:
> chdir dir cmd [args]... - run command in a given directory
> copy file destination - copy file to destination (either file or
>directory)
> copy_if_different in-file out-file - copy file if input has changed
> copy_directory source destination - copy directory 'source' content
>to directory 'destination'
> compare_files file1 file2 - check if file1 is same as file2
> echo [string]... - displays arguments as text
> remove file1 file2 ... - remove the file(s)
> tar [cxt][vfz] file.tar file/dir1 file/dir2 ... - create a tar.
> time command [args] ... - run command and return elapsed time
> create_symlink old new - create a symbolic link new -> old
>
>
>
>
>
>>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
>>
>>
>>
>
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.4.2 (GNU/Linux)
>
>iD8DBQFDx7IEbQdNYqwwwCwRAtHAAJwJPrs1NUln2uTppRii5Ue6lKQjoQCePGvv
>cs98GdV2iabjpaZtC9NekF0=
>=fUWW
>-----END PGP SIGNATURE-----
>_______________________________________________
>CMake mailing list
>CMake at cmake.org
>http://www.cmake.org/mailman/listinfo/cmake
>
>
--
Andy Cedilnik
Kitware Inc.
More information about the CMake
mailing list