<div dir="ltr"><div>Thanks for the tip Jakub.<br><br></div>BTW, I just realized that the <br><pre>[OUTPUT_STRIP_TRAILING_WHITESPACE]<br></pre><div><div><div class="gmail_extra">option of EXECUTE_PROCESS has the same effect of the regex I wrote to strip the trailing linebreaks.<br>
<br></div><div class="gmail_extra">Regards,<br></div><div class="gmail_extra">JON HAITZ<br><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote">On 9 December 2013 09:46, Jakub Zakrzewski <span dir="ltr"><<a href="mailto:jzakrzewski@e2e.ch" target="_blank">jzakrzewski@e2e.ch</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
I only wanted to warn you, that windows "date" command output is locale-specific, so you may get into trouble if you want to use it as anything else than a string literal.<br>
<br>
From: <a href="mailto:cmake-bounces@cmake.org">cmake-bounces@cmake.org</a> [mailto:<a href="mailto:cmake-bounces@cmake.org">cmake-bounces@cmake.org</a>] On Behalf Of Jon Haitz Legarreta<br>
Sent: Montag, 9. Dezember 2013 09:01<br>
To: Matthew Woehlke<br>
Cc: <a href="mailto:cmake@cmake.org">cmake@cmake.org</a><br>
Subject: Re: [CMake] [CMAKE] Getting compilation date through CMake<br>
<div class=""><div class="h5"><br>
BTW, just for other newbies, I think my mistake was that I took another external command example literally:<br>
<br>
EXECUTE_PROCESS(<br>
COMMAND<br>
svnversion -nc "${sourceDir}"<br>
OUTPUT_VARIABLE _out_svnversion<br>
)<br>
Now I guess the above works (without invoking the command prompt) because a FindSubversion.cmake exists in CMake, and there is an svnversion.exe somewhere in my SVN install.<br>
<br>
HTH,<br>
JON HAITZ<br>
<br>
On 9 December 2013 08:53, Jon Haitz Legarreta <<a href="mailto:jhlegarreta@vicomtech.org">jhlegarreta@vicomtech.org</a>> wrote:<br>
Dear Fraser and Matthew,<br>
yes, both approaches work. Thank you.<br>
<br>
There seems to be a trailing endline in the response given by $ENV{COMSPEC} /c date /t, so the following regex helps deleting it:<br>
<br>
STRING(REGEX REPLACE "(\r?\n)+$" "" _date "${_date}")<br>
Thanks again,<br>
JON HAITZ<br>
<br>
<br>
<br>
On 5 December 2013 22:34, Matthew Woehlke <<a href="mailto:matthew.woehlke@kitware.com">matthew.woehlke@kitware.com</a>> wrote:<br>
On 2013-12-05 15:46, Fraser Hutchison wrote:<br>
If you can specify CMake version 2.8.11 as a minimum, you could use<br>
the string(TIMESTAMP ...) command instead:<br>
<br>
string(TIMESTAMP _output "%d/%m/%Y")<br>
<br>
Bear in mind that these only execute when CMake runs (i.e. at configure time)<br>
rather than at build time, so strictly-speaking you're not actually grabbing the<br>
compile date.<br>
<br>
Of course you could put that in a CMake script and execute it with e.g. '${CMAKE_COMMAND} -p ${CMAKE_CURRENT_SOURCE_DIR}/get_date.cmake' in a custom command :-). Then it would truly be the compile date. (Needless to say, the script would need to write the date into some generated source file, e.g. with configure_file.)<br>
<br>
--<br>
Matthew<br>
<br>
<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
<br>
<br>
</div></div></blockquote></div><br></div></div></div></div>