On Thu, Mar 19, 2009 at 11:18 PM, Michael Jackson <
[email protected]> wrote:
> 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.
> So. what is everyone else doing for this?
>
> My main goal is to automate the generation of cmake code like the
> following:
>
> set ( ${${Project_Name}_VERSION} "2009.03.10")
>
> so that I can later use it for OS X bundle building.
>
> On Unix systems I can easily spawn a "date" command to get what I need but
> what to do on windows?
Ugly, but apparently possible with batch file scripting!
http://www.tech-recipes.com/rx/956/windows-batch-file-bat-to-get-current-date-in-mmddyyyy-format/
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.
You could also ask for a CMake command to get the date and/or time.
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.
--
Philip Lowman
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake