[CMake] Copy files to build folder

Tim Hutton tim.hutton at gmail.com
Tue Jan 17 09:25:26 EST 2012


On 17 January 2012 13:21, David Cole <david.cole at kitware.com> wrote:
> If you want to use file GLOB at CMake time, then you have to re-run
> CMake manually when you add or remove a file. There's no way around
> that, because we are not going to monitor your hard drive for
> arbitrary file changes on a continuous basis...

On 17 January 2012 13:22, Rolf Eike Beer <eike at sf-mail.de> wrote:
>> Thanks Andreas, but that leaves us with having to edit the
>> CMakeLists.txt every time we add a pattern file. There must be a
>> better way?
>
> How should CMake find out that it needs to update it's file list then?

It could re-run the FILE(GLOB) on every build? Instead of making a
dependency on a list of files, I would like to make a dependency on
the contents of a folder.

Thanks for all the replies. I understand that the recommended method
is to have an explicit list of files. And I can see the benefits for
avoiding slip-ups like adding a file without checking it in.

What confuses me now is that for packaging we can use the INSTALL command:

# copy the patterns from the source folder
install( DIRECTORY "patterns" DESTINATION "." FILES_MATCHING PATTERN "*.vti")

This does exactly what I want: it finds all the *.vti files from the
"patterns" folder and subfolders. And yet there's no matching command
to achieve this in the normal build? Is using the INSTALL command like
this not recommended?

-- 
Tim Hutton - http://www.sq3.org.uk - http://profiles.google.com/tim.hutton/


More information about the CMake mailing list