I want to run some test targets after they have been built. Currently, I'm using add_custom_target
:
add_custom_target( runTests ALL
COMMAND testExec1
COMMAND testExec2
DEPENDS
testExec1
testExec2
COMMENT "-- Running tests..."
)
With ALL
, this executes every time a build command is used, including when no dependencies have changed. If I remove ALL
, it never executes. The documentation shows ALL
to be optional, but doesn't give any alternatives or go into detail what happens when you leave it out.
If I use add_custom_command( TARGET ... POST_BUILD )
instead, e.g.
add_custom_command( TARGET testExec1 POST_BUILD
COMMAND testExec1
COMMAND testExec2
DEPENDS
testExec1
testExec2
COMMENT "-- Running tests..."
)
then it only runs if the specified target (here testExec1
) has been built, not when a different dependendy changed.
How can I let my tests run if and only if one or more of them have changed?
I would prefer not to create some dummy file with add_custom_command( OUTPUT ... )
, as shown here.