[CMake] Tests without CTest (was Re: Custom target bug...)

Tim Kientzle kientzle at freebsd.org
Thu Aug 20 00:20:38 EDT 2009


David Cole wrote:
> You're using incorrect arguments as DEPENDS. Things that follow DEPENDS 
> should be full path file names... not cmake target names.

Okay, I think I finally figured out how to do what I need (which is,
of course, to run custom test code without using CTest):

   # CMakeLists.txt
   PROJECT(foobar C)
   ADD_CUSTOM_TARGET(run_all_tests)
   ADD_SUBDIRECTORY(foo)

   # foo_test/CMakeLists.txt
   ADD_EXECUTABLE(foo_test foo_test.c)
   ADD_CUSTOM_TARGET(run_foo_test COMMAND foo_test)
   ADD_DEPENDENCIES(run_all_tests run_foo_test)

With this, I can easily add other subdirectories with
their own test code and build up run_all_tests
conditionally depending on which modules are enabled.

I recall someone else asked this list recently about
using DejaGNU tests with CMake; I believe this approach
should work for that as well.

Cheers,

Tim


More information about the CMake mailing list