[CMake] How best to capture the current Date/Time
Eric Noulard
eric.noulard at gmail.com
Fri Mar 20 05:30:20 EDT 2009
2009/3/20 Philip Lowman <philip at yhbt.com>:
> On Thu, Mar 19, 2009 at 11:18 PM, Michael Jackson
> <mike.jackson at bluequartz.net> 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?
I use 'date' on unix and nothing but a "nodate" string 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.
may be the same idea, use TRY_RUN with your home made portable source
to get your string at CMake time.
another solution would be to try to find some script language installed
(perl, python, ...) then EXECUTE_PROCESS with appropriate pieces of code
for getting the date you want.
I think it would be worth a feature request for cmake -E date <format>
the "how to get date" is popping again and again.
--
Erk
More information about the CMake
mailing list