[cmake-developers] Ability to iterate over all targets?

Michael Wild themiwi at gmail.com
Wed Feb 9 10:30:42 EST 2011


On 02/09/2011 04:24 PM, Johan Björk wrote:
> Hi everyone,
> 
> There seems to be quite a few requests to be able to iterate over all the
> targets
> http://www.cmake.org/pipermail/cmake/2010-September/039379.html
> http://www.mail-archive.com/cmake@cmake.org/msg09544.html
> http://www.mail-archive.com/cmake@cmake.org/msg33947.html
> 
> I haven't seen any changes or bug reports allowing this.. has anyone
> considered adding it?
> 
> My usecase is a bit different then the others. I have a common 'core'
> library that itself contains a bunch of static libraries. We have several
> targets that utilize this common core, and for our iPhone target, I must set
> a certain XCode attribute for all targets.
> While overriding the add_library() call works, it feels like an ugly hack.
> 
> Thanks
> /Johan

Then don't override it, wrap it in a function instead. This is
semantically clearer (if you give it a good name) and has the advantage
that it's clear what's going on. Iterating over a list of targets to
modify properties in a possibly distant part of the build system isn't
very transparent IMHO.

That's not to say I wouldn't like to have a way of obtaining a list of
targets defined so far...


Michael



More information about the cmake-developers mailing list