<div class="gmail_quote">On Thu, Mar 19, 2009 at 11:18 PM, Michael Jackson <span dir="ltr"><<a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I am trying to find a nice portable solution for generating version strings based on the date (seems reasonable). I even have my own c++ code that can generate the proper string for me. The problem that I can not seem to get my head around is that I need to compile and run the program at cmake time which probably isn't really going to happen, at least easily.<br>
So. what is everyone else doing for this?<br>
<br>
My main goal is to automate the generation of cmake code like the following:<br>
<br>
set ( ${${Project_Name}_VERSION} "2009.03.10")<br>
<br>
so that I can later use it for OS X bundle building.<br>
<br>
On Unix systems I can easily spawn a "date" command to get what I need but what to do on windows?</blockquote><div><br>Ugly, but apparently possible with batch file scripting!<br><a href="http://www.tech-recipes.com/rx/956/windows-batch-file-bat-to-get-current-date-in-mmddyyyy-format/">http://www.tech-recipes.com/rx/956/windows-batch-file-bat-to-get-current-date-in-mmddyyyy-format/</a><br>
<br>Another option is you could write a small program which uses localtime() and other posix functions to get you the format that you want and then use the output from the program via a CHECK_C_SOURCE_COMPILES configure test. You could unset the cache variable this generates to cause the program to recompile and run on every configure if you wanted. Not sure how you could get it run without recompiling but someone might know of a way.<br>
<br></div></div>You could also ask for a CMake command to get the date and/or time.<br><br>I've been wanting to add a date to one of our docbook manuals for quite some time now so let me know what you come up with. Option #2 could be implemented and shared in CMake/Modules.<br>
<br>-- <br>Philip Lowman<br>