[CMake] Adding a generated source to all multiple targets

Oliver kfsone Smith osmith at playnet.com
Wed Feb 24 18:17:27 EST 2010


David Cole said the following on 2/24/2010 1:25 AM:
> Or this:
>
> http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F
Bizzare. That's where I started. I rolled out all of my changes, stepped 
through recreating them based on the faq again, and this time it 
works... I did an svn diff, none found...

That's half the problem solved -- the bulk of the post was, though: I 
want to automatically generate one of these per-target, so that the 
tolua runs with per-target compiler switches, and so that the resulting 
.cc file is compiled with the per-target compile flags plus any specific 
flags needed to compile that source.

I.e. the origin file is "lua.pkg";
For target "dbproxy" I want to run "tolua++ -n game 
${db_proxy_definitions} ${common_definitions} -o 
${Foo_BINARY_DIR}/lua.dbproxy.cc ${Foo_SOURCE_DIR}/lua.pkg"
For target "statsd" I want to run "tolua++ -n game ${statsd_definitions} 
${common_definitions} -o ${Foo_BINARY_DIR}/lua.statsd.cc 
${Foo_SOURCE_DIR}/lua.pkg"

And to add those .cc files to their respective targets. Obviously I can 
do it by hand, duh, but I have a lot of targets, so before I do go add 
it one at a time, I just want to be sure I'm not missing some mechanism 
for saying "add a variation of this to all targets" or "add a variation 
of this to this list of targets".

- Oliver





More information about the CMake mailing list