<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.pl-c
        {mso-style-name:pl-c;}
span.blob-code-inner
        {mso-style-name:blob-code-inner;}
span.pl-c1
        {mso-style-name:pl-c1;}
span.pl-k
        {mso-style-name:pl-k;}
span.pl-smi
        {mso-style-name:pl-smi;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hi all<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’m trying to add doxygen-generated comments to my Python module build via SWIG using <a href="https://github.com/m7thon/doxy2swig">https://github.com/m7thon/doxy2swig</a>. This means I need to run doxygen first, then run doxy2swig, and only then run swig. However, I’m getting reports that parallel builds are failing (sometimes).<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>My strategy is based on CMake advice and some blogs (e.g. at <span class=pl-c><a href="https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/">https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/</a> ) and relies on creating custom commands to generate the files and custom targets to be able to specify dependencies on those generated files. Somewhat simplified code is below (original is at </span><a href="https://github.com/UCL/STIR/pull/280">https://github.com/UCL/STIR/pull/280</a>)<span class=pl-c><o:p></o:p></span></p><p class=MsoNormal><span class=pl-c><o:p> </o:p></span></p><p class=MsoNormal><span class=pl-c># command that runs doxygen<o:p></o:p></span></p><p class=MsoNormal><span class=pl-c>add_custom_command(<o:p></o:p></span></p><p class=MsoNormal style='text-indent:36.0pt'><span class=pl-c>OUTPUT doxygen.stamp <o:p></o:p></span></p><p class=MsoNormal style='text-indent:36.0pt'><span class=pl-c>DEPENDS ${doxyfile}<o:p></o:p></span></p><p class=MsoNormal style='text-indent:36.0pt'><span class=pl-c>COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} <o:p></o:p></span></p><p class=MsoNormal style='text-indent:36.0pt'><span class=pl-c>COMMAND cmake -E touch doxygen.stamp<o:p></o:p></span></p><p class=MsoNormal style='text-indent:36.0pt'><span class=pl-c>…)<o:p></o:p></span></p><p class=MsoNormal><span class=pl-c># corresponding target<o:p></o:p></span></p><p class=MsoNormal><span class=pl-c>add_custom_target( doc ALL DEPENDS doxygen.stamp)<o:p></o:p></span></p><p class=MsoNormal><span class=pl-c><o:p> </o:p></span></p><p class=MsoNormal><span class=pl-c># command that runs doxy2swig<o:p></o:p></span></p><p class=MsoNormal><span class=pl-c>add_custom_command( <o:p></o:p></span></p><p class=MsoNormal style='text-indent:36.0pt'><span class=pl-c>OUTPUT STIR_DOXY2SWIG.i <o:p></o:p></span></p><p class=MsoNormal style='text-indent:36.0pt'><span class=pl-c>DEPENDS doc <o:p></o:p></span></p><p class=MsoNormal style='text-indent:36.0pt'><span class=pl-c>COMMAND ${PYTHON_EXECUTABLE} doxy2swig.py -c index.xml STIR_DOXY2SWIG.i <o:p></o:p></span></p><p class=MsoNormal><span class=pl-c>) <o:p></o:p></span></p><p class=MsoNormal><span class=pl-c># corresponding target<o:p></o:p></span></p><p class=MsoNormal><span class=pl-c>add_custom_target(doxy2swig DEPENDS STIR_DOXY2SWIG.i)<o:p></o:p></span></p><p class=MsoNormal><span class=pl-c><o:p> </o:p></span></p><p class=MsoNormal><span class=pl-c># now add that target to the SIWG module<o:p></o:p></span></p><p class=MsoNormal><span class=pl-c>add_dependencies(${SWIG_MODULE_stir_REAL_NAME} doxy2swig)<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Any suggestions on what I’m doing wrong? <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Many thanks!<o:p></o:p></p><p class=MsoNormal>Kris<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>PS: I note that FindDoxygen’s doxygen_add_docs merges the add_custom_command and target into one <span class=pl-c>add_custom_target</span>, see <a href="https://github.com/Kitware/CMake/blob/a44191abc489373d295ecaeb5c2eb1573c876a1a/Modules/FindDoxygen.cmake#L1104">https://github.com/Kitware/CMake/blob/a44191abc489373d295ecaeb5c2eb1573c876a1a/Modules/FindDoxygen.cmake#L1104</a> <o:p></o:p></p><p class=MsoNormal>I thought that couldn’t be done but I guess I was wrong.<o:p></o:p></p><p class=MsoNormal>PS: I also note that doxygen_add_docs doesn’t create a doxygen.stamp file to prevent re-runs though, is that not needed then? <o:p></o:p></p></div></body></html>