<br><br><div class="gmail_quote">On 7 July 2010 23:05, Michael Wild <span dir="ltr">&lt;<a href="mailto:themiwi@gmail.com" target="_blank">themiwi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



<div><br>
On 7. Jul, 2010, at 16:01 , Paul Harris wrote:<br>
<br>
&gt; Hi all,<br>
&gt;<br>
&gt; I have looked and can&#39;t find the answer, so I turn to the list.<br>
&gt;<br>
&gt; I have a CMakeLists.txt and a subdirectory called utils, which also has its<br>
&gt; own CMakeLists.txt<br>
&gt;<br>
&gt; In the parent CML.txt, I have something like:<br>
&gt;<br>
&gt; ENABLE_TESTING()<br>
&gt; add_subdirectory(utils)<br>
&gt;<br>
&gt; In my utils CML.txt, I have<br>
&gt;<br>
&gt; ADD_EXECUTABLE(unit_1 units/unit_1.cpp)<br>
&gt; ADD_TEST( unit_1 ${EXECUTABLE_OUTPUT_PATH}/unit_1 )<br>
&gt;<br>
<br>
</div>Simplify this to<br>
<br>
ADD_TEST(unit_1 unit_1)<br>
<br>
CMake will figure out by itself that unit_1 is a target and invoke the executable correctly (your code would break for multi-configuration IDE generators).<br>
<br></blockquote><div><br></div><div>This does not work for me.  If I do not have the EXECUTABLE_OUTPUT_PATH in add_test, I get a message like this when i run &quot;make test&quot; (shortened for brevity):<br><br></div><div>

  1/  1 Testing unit_string_numeric_utils     Could not find executable unit_string_numeric_utils<br>Looked in the following places:<br>unit_string_numeric_utils<br>unit_string_numeric_utils<br>Release/unit_string_numeric_utils<br>

Release/unit_string_numeric_utils<br><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


As for the dependencies, I agree that it would be nice if the &quot;test&quot; target depended on the executables. But what is wrong with &quot;make all test&quot; (apart from the fact that it possibly compiles more than you actually need to run the test)? You could also wrap </blockquote>



<div><br></div><div>I want to only build the tests, because for today&#39;s job, rebuilding my unit tests takes 2 seconds, which I&#39;ll do a dozen times as I add functionality.</div><div>linking the libraries that would be affected by my changes would take 60 seconds or more.</div>



<div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">the add_executable call in a custom function which creates a custom target (say test_exes) and makes it depend on all the executables:<br>



<br></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
function(add_test_executable name)<br>
  if(NOT TARGET ${name})<br>
    add_custom_target(test_exes)<br>
   endif()<br>
   add_executable(${name} ${ARGN})<br></blockquote><div>add_test(${name} ${EXECUTABLE_OUTPUT_PATH}/${name}) <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


   add_dependencies(test_exes ${name})<br>
endfunction()<br>
<br></blockquote><div><br>This works well for me, brilliant!    except I added the add_test() line (above)<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




Then you can do &quot;make test_exes test&quot;.<br><br></blockquote><div><br>This does not work for me, as I run it like so:<br>make -j8 test_exes test   (yes I have 8 CPUs)<br>and that runs the &#39;test&#39; before / in parallel with test_exes.<br>

<br>I have tried to resolve that with my next email to Marcel...<br><br></div>Paul<div><br></div></div>