<br><br><div class="gmail_quote">On 11 July 2010 20:36, Michael Hertling <span dir="ltr">&lt;<a href="mailto:mhertling@online.de">mhertling@online.de</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><div></div><div class="h5">On 07/10/2010 06:54 PM, Paul Harris wrote:<br>
&gt; On 9 July 2010 22:39, Michael Wild &lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; On 9. Jul, 2010, at 15:48 , Michael Hertling wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; On 07/08/2010 09:47 AM, Paul Harris wrote:<br>
&gt;&gt;&gt;&gt; On 8 July 2010 15:31, Michael Wild &lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; On 8. Jul, 2010, at 7:25 , Paul Harris wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; On 8 July 2010 12:56, Michael Wild &lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; On 8. Jul, 2010, at 4:40 , Paul Harris wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; On 7 July 2010 23:05, Michael Wild &lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; On 7. Jul, 2010, at 16:01 , Paul Harris wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Hi all,<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; I have looked and can&#39;t find the answer, so I turn to the list.<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; I have a CMakeLists.txt and a subdirectory called utils, which<br>
&gt;&gt; also<br>
&gt;&gt;&gt;&gt;&gt; has<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; its<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; own CMakeLists.txt<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; In the parent CML.txt, I have something like:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; ENABLE_TESTING()<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; add_subdirectory(utils)<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; In my utils CML.txt, I have<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; ADD_EXECUTABLE(unit_1 units/unit_1.cpp)<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; ADD_TEST( unit_1 ${EXECUTABLE_OUTPUT_PATH}/unit_1 )<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Simplify this to<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; ADD_TEST(unit_1 unit_1)<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; CMake will figure out by itself that unit_1 is a target and invoke<br>
&gt;&gt; the<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; executable correctly (your code would break for multi-configuration<br>
&gt;&gt;&gt;&gt;&gt; IDE<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; generators).<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; This does not work for me.  If I do not have the<br>
&gt;&gt; EXECUTABLE_OUTPUT_PATH<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; in<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; add_test, I get a message like this when i run &quot;make test&quot;<br>
&gt;&gt; (shortened<br>
&gt;&gt;&gt;&gt;&gt; for<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; brevity):<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; 1/  1 Testing unit_string_numeric_utils     Could not find<br>
&gt;&gt; executable<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; unit_string_numeric_utils<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Looked in the following places:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; unit_string_numeric_utils<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; unit_string_numeric_utils<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Release/unit_string_numeric_utils<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Release/unit_string_numeric_utils<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; Mmmh, works fine for me:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; ---------&gt;8---------<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; cmake_minimum_required(VERSION 2.8)<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; project(tmp)<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; enable_testing()<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; add_executable(unit1 unit1.cpp)<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; add_test(unit1 unit1)<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; ---------&lt;8---------<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; Where unit1.cpp is just a simple hello-world program. Running it:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; snip<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; My project is a lot bigger than a hello-world program.  It has<br>
&gt;&gt;&gt;&gt;&gt;&gt; subdirectories for a start, and I do things like<br>
&gt;&gt;&gt;&gt;&gt;&gt; SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL<br>
&gt;&gt;&gt;&gt;&gt; &quot;Single<br>
&gt;&gt;&gt;&gt;&gt;&gt; output directory for building all executables.&quot;)<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; I&#39;m not sure at which point things stop working, do you want me to try<br>
&gt;&gt;&gt;&gt;&gt; and<br>
&gt;&gt;&gt;&gt;&gt;&gt; build a test-case?<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; You are right, it seems that the documentation is misleading (or IMHO<br>
&gt;&gt;&gt;&gt;&gt; outright wrong). This, however, works for me and is safe:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; add_test(NAME unit1 COMMAND $&lt;TARGET_FILE:unit1&gt;)<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Note that NAME and COMMAND are required for this to work.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; BTW: EXECUTABLE_OUTPUT_PATH is deprecated, you should use<br>
&gt;&gt;&gt;&gt;&gt; CMAKE_RUNTIME_OUTPUT_DIRECTORY instead.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I changed EXE to that CMAKE RUNTIME thing, thanks.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; That NAME/COMMAND thing doesn&#39;t work for me at all.  Can&#39;t find the<br>
&gt;&gt; binary<br>
&gt;&gt;&gt;&gt; without the runtime output path explicitly added.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; This is what I tried:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; In parent CMakeLists.txt<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; ENABLE_TESTING()<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; set (CMAKE_TEST_COMMAND ctest -V)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; function (add_unit_test name)<br>
&gt;&gt;&gt;&gt;   if(NOT TARGET ${name})<br>
&gt;&gt;&gt;&gt;      add_custom_target (check COMMAND ${CMAKE_TEST_COMMAND})<br>
&gt;&gt;&gt;&gt;   endif()<br>
&gt;&gt;&gt;&gt;   add_executable(${name} ${ARGN})<br>
&gt;&gt;&gt;&gt;   add_test(NAME ${name} COMMAND $&lt;TARGET_FILE:${name}&gt;)<br>
&gt;&gt;&gt;&gt;   add_dependencies(check ${name})<br>
&gt;&gt;&gt;&gt; endfunction()<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; in subdirectory CMakeLists.txt<br>
&gt;&gt;&gt;&gt; add_unit_test(unit_string_numeric_utils<br>
&gt;&gt; units/unit_string_numeric_utils.cpp<br>
&gt;&gt;&gt;&gt; string_numeric_utils.cpp)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Could you detect manually where the binary in question gets written<br>
&gt;&gt;&gt; to, and post ctest&#39;s output with the complaint about not finding it,<br>
&gt;&gt;&gt; and perhaps you could also post a minimal CMakeLists.txt file which<br>
&gt;&gt;&gt; demonstrates this issue along with the output of &quot;make VERBOSE=1&quot;?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Regards,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Michael<br>
&gt;&gt;<br>
&gt;&gt; I suspect he&#39;s using a pre-2.8 version of CMake. I confirmed that add_test<br>
&gt;&gt; only resolves executable target names if used with NAME and COMMAND, and<br>
&gt;&gt; this signature was introduced in 2.8.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt; I&#39;m using 2.8.1<br>
&gt; Michael Hertling - do you still want me to follow up as you asked?<br>
<br>
</div></div>Yes, of course, if the problem still persists. Until now, I haven&#39;t<br>
managed to let CTest miss an executable previously built by CMake,<br>
i.e. ADD_TEST(NAME ... COMMAND ...) always worked well for me.<br>
<br>
Regards,<br>
<div><div></div><div class="h5"><br>
Michael<br>
<br></div></div></blockquote><div><br><br>Ok first thing: I had two cmakes on my system, one was 2.8.1, and an older 2.6.3 that snuck in through an incorrect script of mine.<br><br>Second thing: the TARGET_FILE thing works.  But the usual add_test(name command) does not.<br>

<br>Ok here we go, minimal test case is attached (uses cmake 2.8.1),<br>procedure:<br><br>save all files into /tmp/test<br>mkdir /tmp/build<br>cd /tmp/build<br>cmake ../test/ &amp;&amp; make VERBOSE=1 check<br><br>results of that are attached as result.txt<br>

<br>thanks<br>Paul<br><br></div></div>