title: How can I install a hierarchy of files using CMake?
body: <p>I've created a list of files using:</p>
  
  <pre><code>file(GLOB_RECURSE DEPLOY_FILES "${PROJECT_SOURCE_DIR}/install/*")
  </code></pre>
  
  <p>I want to install all of these files in <code>/usr/myproject/</code>, but I want to maintain the file tree on the installed folder:</p>
  
  <pre><code>install/junk
  install/other/junk2
  install/other/junk3
  </code></pre>
  
  <p>If I use:</p>
  
  <pre><code>install(FILES ${DEPLOY_FILES} DESTINATION "usr/myproject")
  </code></pre>
  
  <p>All the files end up in /usr/myproject as:</p>
  
  <pre><code>/usr/myproject/junk
  /usr/myproject/junk2
  /usr/myproject/junk3
  </code></pre>
  
  <p>How can I make the install command keep track of relative paths?</p>
  
  <p>I've worked around the issue by doing it manually in a <code>for</code> loop:</p>
  
  <pre><code>set(BASE "${PROJECT_SOURCE_DIR}/install")
  foreach(ITEM ${DEPLOY_FILES})
    get_filename_component(ITEM_PATH ${ITEM} PATH)
    string(REPLACE ${BASE} "" ITEM_PATH ${ITEM_PATH})
    install(FILES ${ITEM} DESTINATION "usr/myproject${ITEM_PATH}")
  endforeach()
  </code></pre>
  
  <p>...but this is annoying to do. Surely there's an easier way?</p>
  
  <p>(I can't see anything in the install documentation though...)</p>