[CMake] Re: CMake script return a value
Brandon J. Van Every
bvanevery at gmail.com
Wed Jul 19 15:25:54 EDT 2006
Brad King wrote:
> Brandon J. Van Every wrote:
>
>> Brandon J. Van Every wrote:
>>
>>> Can a CMake script invoked with
>>>
>>> EXECUTE_PROCESS(
>>> COMMAND ${CMAKE_COMMAND} -P myscript.cmake
>>> RESULT_VARIABLE myresult
>>> )
>>>
>>> return a value? I don't really want to use stdout. I need that for
>>> status messages. I could regex the stdout to extract a decorated
>>> string, but that's bletcherous. What I want is to do something like
>>> RETURN(${value}) and have RESULT_VARIABLE pick it up.
>>>
>> I realized a further problem, that ADD_CUSTOM_COMMAND and
>> ADD_CUSTOM_TARGET can't have EXECUTE_PROCESS in them. They can only
>> call scripts, and the scripts do not return values. So, there's no way
>> to directly return a value from a script to a build rule.
>>
>
> If you just need to know whether there was an error, have the script
> exit with MESSAGE(FATAL_ERROR ...) in the error case.
No I wanted a value.
> Otherwise you can
> add a feature request for an EXIT command or something like it. There
> is actually no reason that the same set of commands needs to be
> available in project mode and script mode, so we could just add
> scripting-specific commands like EXIT when needed.
>
Hmm, true. Ok I'll add a feature request. There are actually 2
requests: an EXIT(value) that other CMake scripts can pick up, and a way
to retain state between COMMANDs in an ADD_CUSTOM_COMMAND that does not
require writing files.
Cheers,
Brandon Van Every
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20060719/ffe95d65/attachment.html
More information about the CMake
mailing list