[CMake] Adding a generated source to all multiple targets

Tyler Roscoe tyler at cryptio.net
Thu Feb 25 16:32:03 EST 2010


On Wed, Feb 24, 2010 at 07:23:55PM -0600, Oliver kfsone Smith wrote:
> Ok - I just wanted to make sure there wasn't some built-in way of doing 
> it before I plowed ahead with that :)

Nope. Writing your own wrapper for add_* commands seems to be a pretty
common practice.

> >making all the config variables for that target match the form
> >dbproxy_WHATEVER lets you say stuff like:
> >
> >add_library(${this_target} ${${this_target}_SOURCE_FILES} ...)
> >   
> Hmm - I didn't know you could do that, so I've been doing everything 
> project relative, but then the size of this project and the number of 
> sub-targets, and the huge amount of shared code between targets means 
> that things aren't really organized by target, so all of the targets sit 
> in one top-level project.

You are definitely not the first build engineer tasked with modernizing
a crufty legacy codebase.

I recommend making friends with add_subdirectory() as soon as you can.
Once you start breaking the build up into parts, it becomes easier to
manage. The external project stuff may also be worth a look, but
probably not until you tease some modules out of your big ball of mud.

tyler


More information about the CMake mailing list