<br><br><div><span class="gmail_quote">On 10/4/07, <b class="gmail_sendername">Atwood, Robert C</b> &lt;<a href="mailto:r.atwood@imperial.ac.uk">r.atwood@imperial.ac.uk</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi:<br>I have applied Cmake to a pre-existing project that used to use plain<br>make-files that I crafted with great amounts of hair-tearing, and so far<br>cmake was relatively easy and I am now a convert :=&gt; Maybe my hair will
<br>even grow back...<br><br><br>However, there&#39;s a little thing I have not quite figured out. I have had<br>a policy of trying to keep enough information embedded in the executable<br>to ensure that the exact code used to build it may be obtained, using a
<br>script embedded in the Makefile to place some strings, provided by<br>version control software etc., into the code.</blockquote><div><br>I do this:<br><br>Create a custom target that creates a header file based running a script:
<br><br>&nbsp;&nbsp;&nbsp; add_custom_target(version_header_file<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND perl5 GenerateVersion.pl <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMENT &quot;Generating version info&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WORKING_DIRECTORY ${util_dir}<br>&nbsp;&nbsp;&nbsp; ) <br></div><br></div>The perl script does something like this:
<br><br>open SVN, &quot;$svn info |&quot; || die;<br><br>while (&lt;SVN&gt;) {<br>&nbsp;&nbsp;&nbsp; if (/Revision/) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s/Revision: //;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $svn_ver = $_;<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>and then modifies the header file if the version has changed (it writes the header to a temp file and diffs the temp file with the real header, and overwrites the header if there is a change).&nbsp; Writing to a temp file and comparing the files allows the script to run for every build, but it only causes recompiles if the version has changed.&nbsp; This approach works on both Unix and Windows.&nbsp; On Windows, we take the svn rev number and use it in the windows version resource.&nbsp; So the official windows version is something like 
a.b.c.svn rev number<br><br>Regards,<br><br>Omar<br><br>