Re: [CMake] Add lots of commands

2008-03-04 Thread David Cole
You could do this: (I haven't tried, but it should work unless you have a
bunch of fancy stuff in ${entry} that will need escaping...)

SET(commands "")

FOREACH(entry ${entries})
  SET(commands ${commands}
COMMAND ${entry}
)
ENDFOREACH(entry)

ADD_CUSTOM_COMMAND(TARGET  POST_BUILD
  ${commands}
)


HTH,
David

On 3/3/08, Robert Bielik <[EMAIL PROTECTED]> wrote:
>
> In ADD_CUSTOM_COMMAND(TARGET  POST_BUILD
>  COMMAND cmd1 args1
>  [COMMAND cmd2 args2]
> )
>
> I'd need to be able to add as many commands as are in a list, sort of
> like:
>
> In ADD_CUSTOM_COMMAND(TARGET  POST_BUILD
> FOREACH(entry)
>  COMMAND ${entry}
> ENDFOREACH(entry)
> )
>
> Is it possible to achieve this is some way?
>
> TIA
> /R
>
>
> ___
> CMake mailing list
> CMake@cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Add lots of commands

2008-03-03 Thread Brandon Van Every
On Mon, Mar 3, 2008 at 11:24 AM, Robert Bielik <[EMAIL PROTECTED]> wrote:
> In ADD_CUSTOM_COMMAND(TARGET  POST_BUILD
>  COMMAND cmd1 args1
>  [COMMAND cmd2 args2]
>  )
>
>  I'd need to be able to add as many commands as are in a list, sort of like:
>
>  In ADD_CUSTOM_COMMAND(TARGET  POST_BUILD
>  FOREACH(entry)
>  COMMAND ${entry}
>  ENDFOREACH(entry)
>  )
>
>  Is it possible to achieve this is some way?

Not in any nice way.  You've hit the dis-unity of add_custom_command
with other things.  You could write all your commands out to a file,
and then execute that file as a CMake script.  But you can only use
FOREACH at configuration time, so if for some odd reason you're trying
to construct commands at build time after CMake is gone, that won't
work.  Assuming you are getting all your commands at configuration
time and that their configuration is static, you could do:

# make a chain of dependent targets, each executing 1 command
add_custom_command(TARGET mytargetname)
set(chain_num 0)
set(prevchain_name mytargetname)
foreach(entry ${some_command_list})
  set(thischain_name chain${chain_num})
  add_custom_command(TARGET ${thischain_name}
COMMAND ${entry})
  add_dependencies(${prevchain_name} ${thischain_name})
  math(EXPR chain_num "${chain_num} + 1")
  set(prevchain_name ${thischain_name})
endforeach(entry)

I have used this kind of dependency chaining approach to automagically
disambiguate conditionals in Autoconf Makefile.in's.  Autoconf allows
conditionals inside of makefile targets and CMake does not.  If you
happen to be worrying about that kind of problem, and you have lots of
Makefile.in's to worry about, I'd strongly suggest you look at the
code I did for Mozilla.  There's a chance it might just parse your
conditionals into sanity, breaking them into appropriate dependent
chains.  Of course I wrote that code for Mozilla, not the rest of the
world, so no guarantees.  I'm willing to advise on what must be done
for anyone's specific purposes though.  The code is available under
Mozilla's usual tri-license.
https://bugzilla.mozilla.org/show_bug.cgi?id=416982


Cheers,
Brandon Van Every
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Add lots of commands

2008-03-03 Thread Robert Bielik

In ADD_CUSTOM_COMMAND(TARGET  POST_BUILD
COMMAND cmd1 args1
[COMMAND cmd2 args2]
)

I'd need to be able to add as many commands as are in a list, sort of like:

In ADD_CUSTOM_COMMAND(TARGET  POST_BUILD
FOREACH(entry)
COMMAND ${entry}
ENDFOREACH(entry)
)

Is it possible to achieve this is some way?

TIA
/R


___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake