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