-
Notifications
You must be signed in to change notification settings - Fork 22
Target for copying files and directories
Mayeul d'Avezac edited this page May 23, 2014
·
3 revisions
It is sometimes useful to copy files form one place to another during the compilation stage. For instance, this makes it possible to create a python package inside the build directory and use it during testing. The process is to create a dummy target and add files to it:
include(TargetCopyFiles)
add_custom_target(mynewtarget ALL)
add_copy_files(mynewtarget thisfile DESTINATION this/directory)
add_copy_directory(mynewtarget path/to/this/directory
RELATIVE path/to
DESTINATION copy/to/here
GLOB *.h
EXCLUDE *.c
)
A few options are available, as described below:
add_copy_files(
<target> ## target name
[DESTINATION <destination>] # directory where files will be copied
# Defaults to current binary directory
[GLOB <glob>] ## a glob to find target files to copy
[REPLACE <pattern> <replacement>] ## string(REGEX REPLACE) arguments on output filename
[FILES <list of files>] ## list of files to copy. Cannot be used with GLOB or ARGN.
[<list of files>] ## list of files to copy. Cannot be used with GLOB or FILES.
)
add_copy_directory(<target> ## target name
<path> ## directory to copy stuff from
[DESTINATION <path>] ## directory where stuff is copied
# Defaults to current binary dir
[RELATIVE <path>] ## files placed in <destination> from <directory>
# will be named relative to this directory.
# Defaults to <directory>.
# In the example above, "copy/to/here" will contain
# files such as "this/directory/somefile"
[GLOB <glob0> <glob1> ...] ## Patterns copied files should match. Defaults to "*".
[EXCLUDE <glob0> <glob1> ...] ## Patterns of files that should not be copied
)