[CMake] Adding install dependency to test-target?
Hugo Heden
heden at foi.se
Thu Nov 20 10:58:12 EST 2008
Eric Noulard wrote:
>> Good day all,
>>
>>
>> Is there any way that I can add 'install' dependency to the 'test'-target?
>>
>> Doing
>>
>> add_dependencies( test install )
>>
>> does not seem to work:
>> CMake Error at ... (ADD_DEPENDENCIES):
>> add_dependencies Adding dependency to non-existent target: test
>>
> May be you can try to add a first "fake test" which does it:
>
> ADD_TEST(00_Install ${CMAKE_BUILD_TOOL} install)
Aha, I did not think about that, that's very nice, thanks a lot Eric!
(But for future reference, see below)
> I don't think it's possible to add dependencies to "built-in" CMake target
> (which deserve a feature request :-)
>
Ok, I'll file one (unless prompted not to, pending any future discussion
here -- I don't really have a valid use-case!)
----
I realized that I don't really have a valid use-case for letting 'test'
depend on 'install', and I think there could never be one.
Reasoning: In any context where it would be unsafe to invoke 'test'
without 'install', one would want to do something like
add_dependencies( test install )
or, as Eric suggested,
ENABLE_TESTING()
# First test:
ADD_TEST(00_Install ${CMAKE_BUILD_TOOL} install)
But this will not work: The user (developer..) could always *select*
tests using ctest -R from the command line, like
$ ctest -R Blabla
in which case the 'install' target will *not* be invoked before the
tests. For this reason, each and every test must depend on that
everything is installed (e.g each test could start with invoking
${CMAKE_MAKE_PROGRAM} install) ..
Now, this is unfortunate, because checking that installation is
up-to-date takes a bit of time. And when _N_ tests are run, for example
by invoking 'make test', this installation-is-up-to-date check is
performed _N-1_ times too many.
There are probably ways to resolve this.. but I haven't yet.
Ok, thanks for reading!
Best Regards
Hugo Heden
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081120/e5ac1296/attachment.htm>
More information about the CMake
mailing list