Search code examples
cmakeroscatkin

automatically execute a script after catkin_make doc


I wonder whether is possible to configure catkin somehow to automatically run a script (or CMake function) when catkin_make doc is called.

I have many different doxygen index.html files (one for each ROS package) and I am using CMake to store a log.txt with the location of the index.html. Then I would like to run a CMake configure_file command using the input from the log.txt file.


Solution

  • Simple Solution

    The probably simplest way is to write a small wrapper script, that first calls catkin and then your script. Something like:

    #!/bin/bash
    catkin_make doc
    your_script.sh
    

    Of course, this could be made more sophisticated by, for example, first checking if some errors occurred during catkin_make.

    CMake Solution

    If the simple solution is not an option (for example, because we don't want to break the workflow of other users), it is also possible to add a "post build" command for a target in CMake with add_custom_command using the "POST_BUILD COMMAND" option:

    add_custom_command(TARGET doc
        POST_BUILD COMMAND your_script.sh
    )
    

    (I am not sure if this will work as intended for target doc, maybe you have to experiment a bit.)