[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    [CMake] How to Redirect Output and Ignore Command Failures
From:       "Mike Howells" <mike.howells () smartsgroup ! com>
Date:       2009-08-31 2:52:53
Message-ID: 3F1F0F58C1AB3449B46F78B6F106D186038E091E () 34093-C6-EVS1 ! exchange ! rackspace ! com
[Download RAW message or body]

--===============0082038965==
Content-class: urn:content-classes:message
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01CA29E6.250D86D3"

This is a multi-part message in MIME format.


I'm creating a custom target to get XML output from my Boost.test test
cases for use in Hudson, and I want the output for all tests to be
generated even if some fail. 

Unfortunately there are two blockers:
1.	cmake makes the first test case to fail stop the build.
2.	cmake offers no way to redirect output and using ">" doesn't
seem to work.

Is there a way to tell cmake to:
1.	Redirect output from a custom command?
2.	Ignore the return status from a custom command? 

Here's my CMakeLists.txt fragment, where exeFiles holds the list of test
case executables:

foreach(exeName ${exeFiles})
  list(APPEND xmlList ${exeName}.xml)
  add_custom_command(OUTPUT ${exeName}.xml
    COMMAND ${exeName} --output_format=XML --log_level=all
--report_level=no
      >${exeName}.xml VERBATIM)
endforeach()

add_custom_target(xmltest DEPENDS ${xmlList})



[Attachment #3 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>How to Redirect Output and Ignore Command Failures</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Calibri">I&#8217;m creating a custom target \
to get XML output from my Boost.test test cases for use in Hudson, and I want the \
output for all tests to be generated even if some fail. </FONT></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Calibri">Unfortunately there are two \
blockers:</FONT></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"><FONT \
FACE="Calibri">1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"> <FONT \
FACE="Calibri">cmake makes the first test case to fail stop the \
build.</FONT></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"><FONT \
FACE="Calibri">2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></SPAN><SPAN LANG="en-us"> \
<FONT FACE="Calibri">cmake offers no way to redirect output and using \
&#8220;&gt;&#8221; doesn&#8217;t seem to work.</FONT></SPAN><SPAN \
LANG="en-us"></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Calibri">Is there a way to tell cmake \
to:</FONT></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"><FONT \
FACE="Calibri">1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"> <FONT \
FACE="Calibri">Redirect output from a custom command?</FONT></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"><FONT \
FACE="Calibri">2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></SPAN><SPAN LANG="en-us"> \
<FONT FACE="Calibri">Ignore the return status from a custom command? \
</FONT></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Calibri">Here&#8217;s my CMakeLists.txt \
fragment, where exeFiles holds the list of test case executables:</FONT></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier New">foreach(exeName \
${exeFiles})</FONT></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier \
New">&nbsp;</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"> <FONT COLOR="#000080" SIZE=2 FACE="Courier New">list</FONT></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT \
COLOR="#000000" SIZE=2 FACE="Courier New">(APPEND xmlList</FONT></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"> <FONT \
COLOR="#7F0055" SIZE=2 FACE="Courier New">${exeName}.xml</FONT></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT \
COLOR="#000000" SIZE=2 FACE="Courier New">)</FONT></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier \
New">&nbsp;</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"> <FONT COLOR="#000080" SIZE=2 FACE="Courier \
New">add_custom_command</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier \
New">(OUTPUT</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"> <FONT COLOR="#7F0055" SIZE=2 FACE="Courier \
New">${exeName}.xml</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier New">&nbsp;&nbsp;&nbsp; \
COMMAND</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"> <FONT COLOR="#7F0055" SIZE=2 FACE="Courier \
New">${exeName}</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier \
New"> --output_format=XML --log_level=all --report_level=no</FONT></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier \
New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#7F0055" SIZE=2 FACE="Courier \
New">${exeName}.xml</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier \
New"> VERBATIM)</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Courier \
New">endforeach</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier \
New">()</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"><FONT COLOR="#000080" SIZE=2 FACE="Courier \
New">add_custom_target</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier \
New">(xmltest DEPENDS</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"> <FONT COLOR="#7F0055" SIZE=2 FACE="Courier \
New">${xmlList}</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT COLOR="#000000" SIZE=2 FACE="Courier \
New">)</FONT></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN \
LANG="en-us"></SPAN></P>

<P DIR=LTR><SPAN LANG="en-us"></SPAN></P>

</BODY>
</HTML>



_______________________________________________
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
--===============0082038965==--

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic