[CMake] emulating `make check' behaviour

Asmodehn Shade asmodehn at gmail.com
Tue Aug 15 18:32:27 EDT 2006


Hello,

In my case I am using a simple variable BUILD_TESTS in the CMake build to generate or not the tests targets.
after that :

> ccmake
> make
> ctest
 
There is a problem though, but not that important for me :
I need to rerun ccmake to change the value for the BUILD_TESTS variable.
But I dont mind, I rarely do coding the library project and the test project at the same time.
Switch mode : ccmake
Test mode : make && ctest
Lib mode : make && ctest

So that works for me ;) This will solve your 1), but not your 2) (maybe you can have only one main test target called 'test' or 'check' ?)

Good luck ;)

On Tue, 15 Aug 2006 13:09:17 -0400
Scott Amort <jsamort at gmail.com> wrote:

> 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
> 
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list