[CMake] emulating `make check' behaviour

Scott Amort jsamort at gmail.com
Tue Aug 15 13:09:17 EDT 2006


Hello,

I am attempting to emulate the autotools `make check' behaviour in my
CMake project.  I currently have a testing framework setup and working
using ENABLE_TESTING() and CTest, however, it has two drawbacks (from my
perspective, anyways ;-) ).

1) Testing executables are compiled at the same time as the project
(i.e. when `make' is executed).  I would prefer these to only compile
when explicitly requested with `make test'.

2) `make test' only executes ctest with no dependencies on the testing
executables (i.e. if I make a change to the testing code, I need to
rerun `make' and then `make test').

I enquired about this a little while back, and it was suggested to use
ctest with --build-and-test, however, I can't seem to find any
documentation on what this actually does.  It appears to be independent
of the CMake build process, however, so it is likely not the solution I
am after.

Does anyone have any suggestions on how to proceed?  My current idea is
to create an optional subproject that is the testing executable(s) and
link that to an ADD_CUSTOM_TARGET, however, I don't think it is possible
to selectively compile projects with this command.  If anyone could
offer some assistance, it would be greatly appreciated.

Best,
Scott



More information about the CMake mailing list