And that leads to the idiomatic way to do this in CMake: create a custom command to produce the output you want (let’s call it X
), and then create a custom target that will DEPENDS
on the custom command’s output (X
). The target will always build, but since it won’t have a COMMAND
, all it will do is bring its dependencies (i.e. X
) up to date. If X
doesn’t exist or is out of date, the custom command will build it. If X
is up to date, nothing happens.