title: Copying files and including them in a CPack archive
body: <p>So, there are numerous ways to copy files (and directories) at <code>CMake</code> runtime (<code>file(COPY ...)</code>, <code>configure_file(...)</code> and <code>add_custom_command()</code> all work*), but I haven't yet found out how to make a file or directory copied from the source to build directory appear in an archive generated by CPack.  I though that <a href="https://stackoverflow.com/a/10672739/889604">this SO answer</a> would fix it, as it actually links the copying to a target which will then have an install linked to it:</p>
  
  <pre><code>install(TARGET mytarget DESTINATION bin)
  </code></pre>
  
  <p>whereas I did recognise that the <code>file()</code> and <code>configure_file()</code> commands don't have an obvious way to be added to a target. But, this didn't work.  So, given a simple CMakeLists.txt, such as the one below, how do I make all of the files (including the <code>exmaple</code> directory) appear in the archive?!</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
  enable_language(FORTRAN)
  add_executable(mytarget ${PROJECT_SOURCE_DIR}/myprog.for)
  install(TARGETS mytarget DESTINATION bin)
  
  add_custom_command(TARGET mytarget PREBUILD
                  COMMAND ${CMAKE_COMMAND} -E copy_directory
                    ${PROJECT_SOURCE_DIR}/examplefiles ${PROJECT_BINARY_DIR}/examplefiles)
  
  set(CPACK_GENERATOR "TGZ")
  include(CPack)
  </code></pre>
  
  <p>* I haven't yet found out which one of these 3 methods is actually (most?) correct - so any advice on this too will be hugely appreciated</p>