[CMake] add_custom_command question

Michael Hertling mhertling at online.de
Thu Oct 20 19:06:37 EDT 2011


On 10/20/2011 08:23 PM, Łukasz Tasz wrote:
>> add_custom_target(TARGET generator
>>                COMMAND touch aaa.cxx
>>                COMMENT generate file
>> )
>>
>> add_custom_command(OUTPUT aaa.cxx
>>                COMMAND echo "command"
>>                DEPENDS generator bar
>> This does not work^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>                COMMENT "i'm just echo"
>> )
>> add_executable(bar EXCLUDE_FROM_ALL c.cxx)
>> add_executable(foo aaa.cxx)
>>
>> error is:
>> [ 33%] Built target bar
>> make[2]: *** No rule to make target `../generator', needed by `aaa.cxx'.  Stop.
>> make[1]: *** [CMakeFiles/foo.dir/all] Error 2
> 
> one my mistake, which is slightly changing the output:
> 
> add_custom_target(generator
>                COMMAND touch aaa.cxx
>                COMMENT generate file
> )
> add_custom_command(OUTPUT aaa.cxx
>                COMMAND echo "command"
>                DEPENDS generator bar
>                COMMENT "i'm just echo"
> )
> add_executable(bar EXCLUDE_FROM_ALL c.cxx)
> add_executable(foo aaa.cxx)
> 
> [  0%] generate file
> [ 25%] Built target generator
> [ 50%] Built target bar
> make[3]: *** No rule to make target `generator', needed by `aaa.cxx'.  Stop.
> 
> 
> regards
> Lukasz

Which version of CMake do you use? This issue should have been resolved
in 2.8.4, see [1]. If it still persists, could you come up with a
minimal but complete example for further investigation?

Regards,

Michael

[1] http://public.kitware.com/Bug/view.php?id=12057


More information about the CMake mailing list