[CMake] more targets to run in parallel

Andrea Crotti andrea.crotti.0 at gmail.com
Mon Feb 20 06:10:48 EST 2012


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?

I was trying the following (nonsense), a simple loop over a list
that first generates a custom command and another loop
that generates a target for every command.

set(target_list uno due tre)

foreach (t ${target_list})
   set(t_cmd ${t}.out)
   add_custom_command(OUTPUT ${t_cmd}
     COMMAND "ls ${t} > ${t_cmd}"
     )
endforeach ()

foreach (t ${target_list})
   message("analyzing target ${t}")
   set(t_cmd ${t}.out)
   add_custom_target(${t}
     COMMAND ${t_cmd}
     )
endforeach ()


I would suppose that this should work but it doesn't:

make[3]: uno.out: Command not found
make[3]: *** [CMakeFiles/uno] Error 127
make[2]: *** [CMakeFiles/uno.dir/all] Error 2
make[1]: *** [CMakeFiles/uno.dir/rule] Error 2
make: *** [uno] Error 2

Any idea why?


More information about the CMake mailing list