title: cmake: issue with target dependencies (add_dependency not working?)
body: <p>I have a small library gathering SCM info for each build. It has 2 targets:  </p>
  
  <ol>
  <li><code>generate_scmversion_inc</code> a custom target running a script on every build, which generates a scmversion.inc file containing SCM info (label, date, time, etc.)</li>
  <li><code>scmversion</code> which compiles SCMVersion.cpp. This cpp file includes scmversion.inc. </li>
  </ol>
  
  <p>On every build I want, in order:</p>
  
  <ul>
  <li>the script to run</li>
  <li>SCMVersion.cpp to rebuild</li>
  </ul>
  
  <p>Towards this goal I declare <code>scmversion</code> to depend on <code>generate_scmversion_inc</code> with:</p>
  
  <p><code>add_dependencies(scmversion generate_scmversion_inc)</code></p>
  
  <p>Result:
  <code>generate_scmversion_inc</code> runs every build as expected. But <code>scmversion</code> strangely only <strong>every second time</strong>. Can someone please tell me what I am doing wrong here?</p>
  
  <p>I'm using CMake 3.4.3 with build system ninja 1.6.0</p>
  
  <p>Code as reference:</p>
  
  <pre><code>project(scmversion)
  
  set (SOURCES
       src/ndd/SCMVersion.cpp)
  
  add_library(${PROJECT_NAME} ${SOURCES})
  
  add_custom_target(generate_scmversion_inc ALL 
                    COMMAND ${CMAKE_COMMAND}
                            -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
                            -P ${CMAKE_CURRENT_SOURCE_DIR}/script/getscm.cmake)
  
  add_dependencies(scmversion generate_scmversion)
  </code></pre>