[CMake] more targets to run in parallel

David Cole david.cole at kitware.com
Mon Feb 20 10:15:41 EST 2012


On Mon, Feb 20, 2012 at 7:58 AM, Andrea Crotti <andrea.crotti.0 at gmail.com>wrote:

> On 02/20/2012 11:51 AM, Eric Noulard wrote:
>
>> 2012/2/20 Andrea Crotti<andrea.crotti.0 at gmail.**com<andrea.crotti.0 at gmail.com>
>> >:
>>
>>> On 02/17/2012 03:35 PM, Andrea Crotti wrote:
>>> ..
>>>
>>> I can make the question much simpler, is it possible to generate targets
>>> dynamically with CMake?
>>>
>> As far as I know you can "generate" targets at CMake-time but not at
>> build-time.
>> So from my point of view this "computed target" but not really "dynamic
>> target".
>> if you want your target to trigger the command you may
>> add the OUTPUT of the command as a dependency of the target.
>>
>> add_custom_target(${t}
>>     DEPENDS ${t_cmd}
>>                             )
>>
>>
>>
> Ah thanks now I got it, I thought that the name of the custom_command was
> given
> from the OUTPUT, for some strange reason.
>
> Doing this however:
>
> foreach (t ${target_list})
>  set(t_cmd ${t}.out)
>  add_custom_command(OUTPUT ${t_cmd}
>    COMMAND "ls ${t}"
>    )
> endforeach ()
>
> foreach (t ${target_list})
>  message("analyzing target ${t}")
>  set(t_cmd ${t}.out)
>  add_custom_target(${t}
>    DEPENDS ${t_cmd}
>    )
> endforeach ()
>
> is still problematic:
> ~/psi_diet/test_cmake $ make uno
> [100%] Generating uno.out
> /bin/sh: ls uno: command not found
> make[3]: *** [uno.out] Error 127
>
>
>
> So I tried an even simpler example:
> add_custom_command(OUTPUT simple
>  COMMAND "ls -l"
>  )
>
> add_custom_target(simple
>  DEPENDS simple
>  )
>
>
> and everything works apparently, but it doesn't generate the "simple"
> file..
> How do I generate an output file which is used as dependency of the
> "simple"
> target then?
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/**
> opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/**CMake_FAQ<http://www.cmake.org/Wiki/CMake_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
>


Use:

  COMMAND ls -l

Not:

  COMMAND "ls -l"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120220/16d2e82a/attachment.htm>


More information about the CMake mailing list