Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake & CTest : make test doesn't build tests

I'm trying CTest in CMake in order to automatically run some of my tests using make test target. The problem is CMake does not "understand" that the test I'm willing to run has to be built since it is part of the project.

So I'm looking for a way to explicitly specify this dependency.

like image 499
claf Avatar asked Apr 09 '09 09:04

claf


1 Answers

It is arguably a bug in CMake (previously tracked here) that this doesn't work out of the box. A workaround is to do the following:

add_test(TestName ExeName) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}                   DEPENDS ExeName) 

Then you can run make check and it will compile and run the test. If you have several tests, then you would have to use DEPENDS exe1 exe2 exe3 ... in the above line.

like image 165
richq Avatar answered Oct 19 '22 01:10

richq