Thanks for the tip Jakub. BTW, I just realized that the
[OUTPUT_STRIP_TRAILING_WHITESPACE] option of EXECUTE_PROCESS has the same effect of the regex I wrote to strip the trailing linebreaks. Regards, JON HAITZ On 9 December 2013 09:46, Jakub Zakrzewski <jzakrzew...@e2e.ch> wrote: > Hi, > 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. > > From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf > Of Jon Haitz Legarreta > Sent: Montag, 9. Dezember 2013 09:01 > To: Matthew Woehlke > Cc: cmake@cmake.org > Subject: Re: [CMake] [CMAKE] Getting compilation date through CMake > > BTW, just for other newbies, I think my mistake was that I took another > external command example literally: > > EXECUTE_PROCESS( > COMMAND > svnversion -nc "${sourceDir}" > OUTPUT_VARIABLE _out_svnversion > ) > 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. > > HTH, > JON HAITZ > > On 9 December 2013 08:53, Jon Haitz Legarreta <jhlegarr...@vicomtech.org> > wrote: > Dear Fraser and Matthew, > yes, both approaches work. Thank you. > > There seems to be a trailing endline in the response given by > $ENV{COMSPEC} /c date /t, so the following regex helps deleting it: > > STRING(REGEX REPLACE "(\r?\n)+$" "" _date "${_date}") > Thanks again, > JON HAITZ > > > > On 5 December 2013 22:34, Matthew Woehlke <matthew.woeh...@kitware.com> > wrote: > On 2013-12-05 15:46, Fraser Hutchison wrote: > If you can specify CMake version 2.8.11 as a minimum, you could use > the string(TIMESTAMP ...) command instead: > > string(TIMESTAMP _output "%d/%m/%Y") > > Bear in mind that these only execute when CMake runs (i.e. at configure > time) > rather than at build time, so strictly-speaking you're not actually > grabbing the > compile date. > > 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.) > > -- > Matthew > > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake > > >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake