[CMake] RESULT_VARIABLE of excecute_process inside install() not getting value

David Cole david.cole at kitware.com
Mon Sep 6 10:44:29 EDT 2010


Escape the dollar sign, like so:

install(CODE "
execute_process(COMMAND my_script
               RESULT_VARIABLE ret_val)
MESSAGE(\"install return value is \${ret_val}\")
")

As you had it, ${ret_val} is being evaluated at cmake configure time, and
there is just an empty string in the generated file that runs at install
time... Escaping the "$" allows evaluation as you intend at install time.


HTH,
David


On Mon, Sep 6, 2010 at 10:05 AM, Jacob Avraham <jacob at compass-eos.com>wrote:

> Hi,
> I'm trying to get a return value of a script that I runs from
> execute_process() command,
> as part of an install() command, and I don't see that the return variable
> is getting any value.
> I'm doing something like:
> install(CODE "
> execute_process(COMMAND my_script
>                RESULT_VARIABLE ret_val)
> MESSAGE(\"install return value is ${ret_val}\")
> ")
>
> It does work when not included in an install CODE segment.
>
> Any idea how to get the make to abort when my_script fails?
>
> Thanks,
>
> Jacob
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100906/6463300a/attachment.htm>


More information about the CMake mailing list