Fwd to the list

---------- Forwarded message ----------
From: Benoit RAT (Gmail) <benoit....@gmail.com>
Date: 2009/2/12
Subject: Re: [CMake] Cmake macro and date
To: Eric Noulard <eric.noul...@gmail.com>


Okay it seems to be perl problem therefore I've decided to make the
script directly calling system function:

Here you have an exemple using REGEXP extension:

MACRO (TODAY RESULT)
    IF (WIN32)
        EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE ${RESULT})
        string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1"
${RESULT} ${${RESULT}})
    ELSEIF(UNIX)
        EXECUTE_PROCESS(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
        string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1"
${RESULT} ${${RESULT}})
    ELSE (WIN32)
        MESSAGE(SEND_ERROR "date not implemented")
        SET(${RESULT} 000000)
    ENDIF (WIN32)
ENDMACRO (TODAY)

Hope it can be usefull to someone!

--
Benoit RAT
www.neub.co.nr


On Thu, Feb 12, 2009 at 2:59 PM, Eric Noulard <eric.noul...@gmail.com> wrote:
>
> 2009/2/12 Benoit <benpaka.s...@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




-- 
Erk
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to