Thanks to Craig Scott for his Blog!
A modified example from https://crascit.com
Instead of using add_custom_target()
to generate the sources manually, you should define custom OUTPUTS <files>
with DEPENDS <files>
using
add_custom_command().
CMake can then automatically work out dependencies when those outputs are used as inputs to another target.
Sam Thursfield has more CMake tips if you are intrested.
CMake and Ninja can generate graphviz files showing the dependencies between the targets in a project
This dependency trees DAG are generated with this CMakeLists.txt and dot, a tool from graphviz