[CMake] Add a build event that depends on a target
Pawel Veselov
pawel.veselov at gmail.com
Fri Nov 17 18:09:11 EST 2017
Hi.
Is it possible in some way to add a build event that depends on a target
(different target than what the build event is for)? add_custom_command()
doesn't seem to support that.
What I'm trying to do is:
1) Have target "test", which builds tests
2) Have target "program". Have a post-build build event
that executes test, so that the program is only
fully built when the tests are successful
Simple:
------ cut ------
add_executable(test test.c)
add_executable(program program.c)
enable_testing()
add_test(NAME test COMMAND test)
add_custom_command(
TARGET program
POST_BUILD
COMMAND ${CMAKE_CTEST_COMMAND} -R test
)
------ cut ------
doesn't work, at least in parallel build, there is nothing that prevents
the unit test to run before test is built (which is what happens).
Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171118/dd4abfeb/attachment.html>
More information about the CMake
mailing list