[CMake] more targets to run in parallel
Andrea Crotti
andrea.crotti.0 at gmail.com
Mon Feb 20 07:58:52 EST 2012
On 02/20/2012 11:51 AM, Eric Noulard wrote:
> 2012/2/20 Andrea Crotti<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?
More information about the CMake
mailing list