<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Eric Noulard wrote:<br>
<blockquote type="cite">
  <blockquote type="cite">
    <pre wrap="">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
    </pre>
  </blockquote>
  <pre wrap=""><!----></pre>
</blockquote>
<blockquote type="cite">
  <pre wrap="">May be you can try to add a first "fake test" which does it:

ADD_TEST(00_Install ${CMAKE_BUILD_TOOL} install)</pre>
</blockquote>
Aha, I did not think about that, that's very nice, thanks a lot Eric!
(But for future reference, see below)<br>
<br>
<blockquote type="cite">
  <pre wrap="">I don't think it's possible to add dependencies to "built-in" CMake target
(which deserve a feature request :-)
  </pre>
</blockquote>
Ok, I'll file one (unless prompted not to, pending any future
discussion here -- I don't really have a valid use-case!)<br>
<br>
----<br>
<br>
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. <br>
<br>
Reasoning: In any context where it would be unsafe to invoke 'test'
without 'install', one would want to do something like<br>
<pre wrap="">add_dependencies( test install )
</pre>
or, as Eric suggested, <br>
<pre wrap="">ENABLE_TESTING()
# First test:
ADD_TEST(00_Install ${CMAKE_BUILD_TOOL} install)</pre>
But this will not work: The user (developer..) could always *select*
tests using ctest -R from the command line, like <br>
<br>
$ ctest -R Blabla<br>
<br>
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) .. <br>
<br>
Now, this is unfortunate, because checking that installation is
up-to-date takes a bit of time.&nbsp; And when _N_ tests are run, for
example by invoking 'make test', this installation-is-up-to-date check
is performed&nbsp; _N-1_ times too many. <br>
<br>
There are probably ways to resolve this.. but I haven't yet.<br>
<br>
Ok, thanks for reading!<br>
<br>
Best Regards<br>
Hugo Heden<br>
<br>
<br>
<br>
</body>
</html>