[CMake] Cmake macro and date

Eric Noulard eric.noulard at gmail.com
Thu Feb 12 08:59:27 EST 2009


2009/2/12 Benoit <benpaka.spam at gmail.com>:
> Hy,
>
> I want to retrieve today date in order to install various release each day.
> I've created a script: GetDataTime.cmake
>
> In which I have defined this macro:
>
> INCLUDE(FindPerl)
> MACRO (TODAY RESULT)
> IF (PERL_FOUND)
>     EXECUTE_PROCESS(COMMAND "${PERL_EXECUTABLE}" "-E
> '($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
> printf \"%02d%02d%02d\",$year-100,$mon+1,$mday;'" OUTPUT_VARIABLE ${RESULT})

[...]

> Someone can tell me how to use a macro to retrieve a result because I'm not
> sure to understand!!!!

I think your example should work since this one is working fine:

MACRO (TODAY RESULT)
    EXECUTE_PROCESS(COMMAND echo "MacroSetted" OUTPUT_VARIABLE ${RESULT})
    MESSAGE( STATUS "(in) ${RESULT}")
ENDMACRO (TODAY)

TODAY(FF)
MESSAGE(STATUS "FF = ${FF}")

I think perl execution is behaving strangely when executed from within
execute_process.
I would bet that when executed interactively in a termibnal it works as expected
but does not behave the same way regarding standard output when launch in exec.

-- 
Erk


More information about the CMake mailing list