title: CMake: add dependency to add_custom_command dynamically
body: <p>I have a CMake project with many subprojects.
  Each of them can use a function I provide to generate a small text file with some certain information (by calling add_custom_command).
  At the final step I'd like to combine all those files into one big text file.</p>
  
  <p>I've created a custom command which searches for created files (all in one place) and merges them.</p>
  
  <p>The problem is that I'd like to make this final step dependend on all of small steps being made in subprojects while I don't actually know how many files will be provided.</p>
  
  <p>My final command looks like:</p>
  
  <pre><code>add_custom_command(OUTPUT combination.txt
                     COMMAND create combination.txt from all files from /path/)
  </code></pre>
  
  <p>and my create-small-text-file-for-each-subproject command looks like:</p>
  
  <pre><code>add_custom_command(OUTPUT /path/${sub_project_name}.txt
                     COMMAND create /path/${sub_project_name}.txt)
  </code></pre>
  
  <p>And when I create those small files I'd like to do something like to make "combination.txt" depend on /path/${sub_project_name}.txt</p>
  
  <p>So I wish I could:</p>
  
  <pre><code>add_dependency(combination.txt /path/${sub_project_name}.txt)
  </code></pre>
  
  <p>However this only works for targets.</p>
  
  <p>I've also tried to use set_source_files_properties with OBJECT_DEPENDS, but it seems to doesn't work (maybe its intend to be used with add_target's cpp files ?)</p>
  
  <p>The last way to get it work I see is to use a cache variable which would accumulate all those small files paths and then use it like this:</p>
  
  <pre><code>add_custom_command(OUTPUT combination.txt
                     COMMAND create combination.txt from all files from /path/
                     DEPENDS ${all_small_files_list})
  </code></pre>
  
  <p>but this is the last thing I want to do.</p>