Hi Jon,

You'd have to invoke the command prompt to execute this I think.  On Windows this should be the value of the COMSPEC environment variable, so your command would be something like:

execute_process(COMMAND
    $ENV{COMSPEC} /c date /t
    OUTPUT_VARIABLE _output
)

However, this is Windows-specific.  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.

Cheers,
Fraser.


On 05/12/2013 19:32, Jon Haitz Legarreta wrote:
Hi there,
I was trying to get the compilation time through a CMake-executed command in order to know the compilation time of a given project.
In my custom.cmake file I was using

execute_process(COMMAND
    date -t
    OUTPUT_VARIABLE _output
)

It turns out that the _output variable is empty when I compile my project. However, the command works well from the command line. I'm working on a Win 7  64-bit machine.

I wanted to avoid using an extra C/C++ code file to get the current time.

Am I missing something?

Thank you,
JON HAITZ




--

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

Reply via email to