title: How to copy target files using cmake from major CMakeLists.txt?
body: <p>As an example suppose four folders(app1, app2, app3 and main) such as below</p>
  
  <pre><code>main
  |__ CMakeLists.txt
  \__ module1
  |______ CMakeLists.txt
  |______ sub1.cpp
  |______ sub1.h
  \__ library5
  |______ CMakeLists.txt
  |______ sub5.cpp
  |______ sub5.h
  \__app1
  \__app2
  \__app3
  </code></pre>
  
  <p>Which output of module1 is module1.dll and output of library5 is lib5.dll. Folder of app1 must contain module1.dll and lib5.dll, app2 needs lib5.dll and finally app3 needs module1.dll(number of apps, modules and libs are more than this example and as I explain below we don't want to change modules/libraries's <code>CMakeLists.txt</code>, just main's <code>CMakeLists.txt</code> is ours).</p>
  
  <p><strong>PS:</strong></p>
  
  <p>I have a <code>cmake</code> project which has several libraries and modules. They included in my project using <code>add_subdirectory</code> command (note that my project just made up from multiple modules and it has not any <code>add_library</code> or <code>add_target</code>).</p>
  
  <p>I need to copy outputs of <em>libraries/modules</em> <strong>without</strong> changing their <code>CMakeLists.txt</code> (<code>add_custom_command</code> with <code>POST_BUILD</code> option actually <strong>is not</strong> a good choice because at this point I need to change <code>CMakeLists.txt</code> of libraries/modules which <em>they are not just belong to my project</em>). On the other hand it <strong>must done</strong> in <em>outer(major)</em> <code>CMakeLists.txt</code> which has others(libraries/modules).</p>
  
  <p>I tried some other commands such as <code>file (COPY )</code> and <code>configure_file()</code> but I think they operate in generating <strong><code>cmake-cache</code> phase</strong> and just can copy resource files which are exist in pre-build phase.</p>
  
  <p>Moreover, In another approach I write a bash script file to copy the files and call it in major <code>CMakeLists.txt</code> via bellow command.</p>
  
  <pre><code>add_custom_target (copy_all
          COMMAND ${CMAKE_SOURCE_DIR}/copy.sh ${files}
          WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  )
  </code></pre>
  
  <p>The <code>files</code> has the list of files. But the copy not performed! I manually test the script which works as desired. But I don't have any idea why it can not operate at call in CMakeLists.txt.</p>
  
  <p>What can I do to copy sub-projects outputs to some locations from major <code>CMakeLists.txt</code>?</p>