[CMake] How to make sure "make test" depends on "make all"

Marcel Loose loose at astron.nl
Thu Jun 25 06:30:53 EDT 2009


Hi Shlomi,

It's not completely clear to me how you'd normally run a test. Is that
something like:

$ tap <mytest-prog>

If so, you could do 'add_test(${name} tap ${name})

Best regards,
Marcel Loose.

On Thu, 2009-06-25 at 12:45 +0300, Shlomi Fish wrote:
> On Thursday 25 June 2009 10:35:30 Marcel Loose wrote:
> > Hi Shlomi,
> >
> > If you want to RUN the tests as part of 'make all', I think you're out
> > of luck. 
> 
> No, I don't want that. What I do want is to that "make test" (or alternatively 
> "make check") to depend on "make all" and run it automatically before starting 
> the tests. 
> 
> > In the method I proposed, you can use 'make check', which will
> > build all the test programs and run them. If all your sources have
> > associated test programs, this will effectively build all your source
> > code as well!
> >
> > For this to work, you should use:
> >
> > - add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) (only ONCE!)
> > - The following triad (for each test program):
> >   - add_executable(${name} srcs...)
> >   - add_test(${name} ${name})
> >   - add_dependencies(check ${name})
> >
> 
> This seems like it would build build a few executables and then run them as 
> tests. My test, on the other hand, is a Perl program that runs a few TAP 
> scripts (see http://testanything.org/ ) and depends on the normal executables 
> (that may later get installed or run from ./) to work. So I need a dependency 
> for "make all" on "make check"/"make test".
> 
> Regards,
> 
> 	Shlomi Fish
> 
> > Best regards,
> > Marcel Loose.
> >
> > On Wed, 2009-06-24 at 15:04 +0300, Shlomi Fish wrote:
> > > Hi Marcel!
> > >
> > > On Tuesday 23 June 2009 13:03:25 Marcel Loose wrote:
> > > > Hi Shlomi
> > > >
> > > > You might consider using another target, say 'check'. I've used that to
> > > > mimic more or less the GNU autotools behaviour. See
> > > > http://www.cmake.org/Wiki/CMakeEmulateMakeCheck. Don't use
> > > > EXCLUDE_FROM_ALL if you want your test programs to depend on the target
> > > > 'all'.
> > >
> > > Tried it and it didn't work. I still couldn't get it to run the "all"
> > > target by default (i.e: depend on it). The EXCLUDE_FROM_ALL specifies
> > > whether "check" will be built as part of "all" - not vice versa.
> > >
> > > Regards,
> > >
> > > 	Shlomi Fish
> > >
> > > > Best regards,
> > > > Marcel Loose.
> > > >
> > > > -----Original Message-----
> > > > From: Hugo Heden <hugoheden at gmail.com>
> > > > To: Shlomi Fish <shlomif at iglu.org.il>
> > > > Cc: Cmake Mailing List <cmake at cmake.org>
> > > > Subject: Re: [CMake] How to make sure "make test" depends on "make all"
> > > > Date: Tue, 23 Jun 2009 10:57:16 +0200
> > > >
> > > > On Tue, Jun 23, 2009 at 9:56 AM, Shlomi Fish <shlomif at iglu.org.il>
> > > > wrote:
> > > >         Hi all!
> > > >
> > > >         I'm using cmake-2.6.4-3mdv2010.0 on Mandriva Linux Cooker, and
> > > >         ran into a
> > > >         problem. I want "make test" (which is a custom target) to
> > > > depend on "make
> > > >         all", in this codebase:
> > > >
> > > >
> > > > I can't say that I understand the error messages you're getting, but it
> > > > is unfortunately *not* possible to make built-in targets like "test",
> > > > "all" and "install" depend on each other. See for example this bug:
> > > >
> > > > http://public.kitware.com/Bug/view.php?id=8438
> > > >
> > > >
> > > > _______________________________________________
> > > > Powered by www.kitware.com
> > > >
> > > > Visit other Kitware open-source projects at
> > > > http://www.kitware.com/opensource/opensource.html
> > > >
> > > > Please keep messages on-topic and check the CMake FAQ at:
> > > > http://www.cmake.org/Wiki/CMake_FAQ
> > > >
> > > > Follow this link to subscribe/unsubscribe:
> > > > http://www.cmake.org/mailman/listinfo/cmake
> 



More information about the CMake mailing list