[CMake] custom commands, targets and parallel builds

Kris Thielemans kris.f.thielemans at gmail.com
Sat Nov 24 19:23:00 EST 2018


Hi all

 

I'm trying to add doxygen-generated comments to my Python module build via
SWIG using https://github.com/m7thon/doxy2swig. 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).

 

My strategy is based on CMake advice and some blogs (e.g. at
https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-ta
rgets-and-files-and-custom-commands/ ) 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 https://github.com/UCL/STIR/pull/280)

 

# command that runs doxygen

add_custom_command(

OUTPUT doxygen.stamp 

DEPENDS ${doxyfile}

COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} 

COMMAND cmake -E touch doxygen.stamp

.)

# corresponding target

add_custom_target( doc ALL DEPENDS doxygen.stamp)

 

# command that runs doxy2swig

add_custom_command( 

OUTPUT STIR_DOXY2SWIG.i 

DEPENDS doc 

COMMAND ${PYTHON_EXECUTABLE} doxy2swig.py -c index.xml STIR_DOXY2SWIG.i 

) 

# corresponding target

add_custom_target(doxy2swig DEPENDS STIR_DOXY2SWIG.i)

 

# now add that target to the SIWG module

add_dependencies(${SWIG_MODULE_stir_REAL_NAME} doxy2swig)

 

Any suggestions on what I'm doing wrong? 

 

Many thanks!

Kris

 

PS: I note that FindDoxygen's doxygen_add_docs merges the add_custom_command
and target into one add_custom_target, see
https://github.com/Kitware/CMake/blob/a44191abc489373d295ecaeb5c2eb1573c876a
1a/Modules/FindDoxygen.cmake#L1104 

I thought that couldn't be done but I guess I was wrong.

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? 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181125/f0e0b646/attachment.html>


More information about the CMake mailing list