To produce an error from an install(CODE snippet, simply add:<div><br></div><div>  if(error)</div><div>    message(FATAL_ERROR \&quot;error message here\&quot;)</div><div>  endif()</div><div><br></div><div>inside the CODE based on some other &quot;error&quot; flag also in your CODE...</div>
<div><br><br><div class="gmail_quote">On Wed, Jul 20, 2011 at 7:45 AM, Marcel Loose <span dir="ltr">&lt;<a href="mailto:loose@astron.nl">loose@astron.nl</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Jc,<br>
<br>
Thanks for the tip. It makes sense to let the build fail early (i.e.<br>
during compilation, instead of installation). I&#39;ll take it into<br>
consideration.<br>
<br>
Regards,<br>
<font color="#888888">Marcel Loose.<br>
</font><div><div></div><div class="h5"><br>
On Wed, 2011-07-20 at 06:41 -0400, Jean-Christophe Fillion-Robin wrote:<br>
&gt; Hi Marcel,<br>
&gt;<br>
&gt; Aware I won&#39;t be answering your question regarding the exit code<br>
&gt; associated with INSTALL(CODE ...), I still would like to suggest you<br>
&gt; an approach that could help you addressing your issue.<br>
&gt;<br>
&gt; What about byte-compiling the python source at build time ? In that<br>
&gt; case, the build step would fail instead ...<br>
&gt;<br>
&gt; You could look at macro like this one to help you: See<br>
&gt;<br>
<a href="https://github.com/commontk/CTK/blob/master/CMake/ctkMacroCompilePythonScript.cmake" target="_blank">https://github.com/commontk/CTK/blob/master/CMake/ctkMacroCompilePythonScript.cmake</a><br>
&gt;<br>
&gt; Hth<br>
&gt; Jc<br>
&gt;<br>
&gt; On Wed, Jul 20, 2011 at 3:47 AM, Marcel Loose &lt;<a href="mailto:loose@astron.nl">loose@astron.nl</a>&gt; wrote:<br>
&gt;         Hi all,<br>
&gt;<br>
&gt;         I have a macro that, during install, compiles python source<br>
&gt;         files to<br>
&gt;         byte code. Sometimes, there&#39;s a syntax error in the python<br>
&gt;         source that<br>
&gt;         can be caught during compilation; i.e. during the execution of<br>
&gt;         INSTALL(CODE ...).<br>
&gt;<br>
&gt;         Is is possible to somehow fetch the exit status of commands<br>
&gt;         executed<br>
&gt;         inside INSTALL(CODE ...), so that I can let &#39;make install&#39;<br>
&gt;         exit with a<br>
&gt;         non-zero exit status?<br>
&gt;<br>
&gt;         Best regards,<br>
&gt;         Marcel Loose.<br>
&gt;<br>
&gt;         --<br>
&gt;         Marcel Loose<br>
&gt;         Senior Software Engineer, Computing Group R&amp;D, Astron, the<br>
&gt;         Netherlands<br>
&gt;<br>
&gt;         _______________________________________________<br>
&gt;         Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt;         Visit other Kitware open-source projects at<br>
&gt;         <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt;         Please keep messages on-topic and check the CMake FAQ at:<br>
&gt;         <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
&gt;<br>
&gt;         Follow this link to subscribe/unsubscribe:<br>
&gt;         <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; <a href="tel:%2B1%20919%20869%208849" value="+19198698849">+1 919 869 8849</a><br>
&gt;<br>
<br>
<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br></div>