title: CMake: How to create a file with make command
body: <p>I need to create the following always-out-of-date file: ${CMAKE_BINARY_DIR}/version.hpp.in<br>
  before any target is executed in the make file. The content of file is exactly as the following:</p>
  
  <blockquote>
    <p>#define RELEASE_VERSION "${RELEASE}"<br>
    #define MAJOR_VERSION "${MAJOR}"<br>
    #define MINOR_VERSION "${MINOR}"<br>
    #define PATCH_VERSION "${PATCH}"<br>
    #define REVISION "${REVISION}"<br>
    #define SVNPATH "${SVNPATH}"  </p>
  </blockquote>
  
  <p>I've got the following piece of code in my CMake file, but it's executed only after running the <code>cmake</code> command:</p>
  
  <pre><code>FILE(WRITE ${CMAKE_BINARY_DIR}/version.hpp.in
  "#define RELEASE_VERSION \"${RELEASE}\"\n"
  "#define MAJOR_VERSION \"${MAJOR}\"\n"
  "#define MINOR_VERSION \"${MINOR}\"\n"
  "#define PATCH_VERSION \"${PATCH}\"\n"
  "#define REVISION \"${REVISION}\"\n"
  "#define SVNPATH \"${SVNPATH}\"\n"
  )
  </code></pre>
  
  <p>I want to generate the <code>version.hpp.in</code> file each time I run the <code>make</code> command. How can I do that?</p>